I am using port b to trouble shoot. Everything works fine until I add the rx_loop2 rx_loop is used to filter out all characters entered via RS232 except the letter 'a' If the letter 'a' is choosen I want to then proceed to rx_loop2 and wait for the next character to be entered via RS232, then proceed to tx_loop and send the contents of the w register. My problem is that when I enter the letter 'a' the program proceeds thru rx_loop2 and tx_loop. I have tried to clear the interupt Flag PIR1 , RCIF but that doesn't seem to work I am new at this PIC stuff and after 2 days, I am at a loss! Does anybody have any ideas? Title "RS232 Port" ; list p=16f877,c=140 ; processor type errorlevel 1, -(305) #include "p16f877.inc" ; ; CONFIGURATION BITS: ; ; Oscillator = HS ; Watchdog Timer = Off ; Power Up Timer = On ; Code Protect = Off ; Brown Out Detect = On ; Low Voltage Program = Disabled ; Data EE Protect = Off ; Flash Program Write = Enabled ; Background Debug = Disabled ; ; ; DESCRIPTION: ; ; Baud Rate = 9600, No Parity, 8 bits & 1 Stop Bit, Hardware = None ; ; RS232 | MAX233 MAX233 | 16F877 ; -------------- --------------- ; 2-RX | 5-TX 2-TX | 25-TX ; 3-TX | 4-RX 3-RX | 26-RX ; ; PROGRAM START: ; org 0 ; startup = 0000H clrf STATUS ; bank 0 call main goto start_com org 4 ISR goto 5 org 5 ; main ; call setup_ports call setup_usart call blink ; return ; setup_ports ; banksel PORTA ; bank0 movlw b'00000000' movwf PORTA movlw b'00000000' movwf PORTB movlw b'01000000' movwf PORTC movlw b'00000000' movwf PORTD movlw b'00000000' movwf PORTE banksel TRISA ; bank1 movlw b'00000000' movwf TRISA movlw b'00000000' movwf TRISB movlw b'11000000' ; set RC6 & RC7 as input movwf TRISC movlw b'00000000' movwf TRISD movlw b'11111000' movwf TRISE movlw b'00000111' movwf ADCON1 ; PORTA inputs = digital not analog ; return ; setup_usart ; Baud Values with BRGH = 1 ; ((20000000/9600)/16)-1 = 32 movlw d'129' ; 9600 baud @ 20 Mhz Fosc +0.16 err movwf SPBRG movlw b'00100100' ; brgh = 1 movwf TXSTA ; enable Async Transmission, set brgh banksel RCSTA ; bank0 movlw b'10010000' movwf RCSTA ; enable Async Reception movf RCREG,w movf RCREG,w movf RCREG,w ; flush receive buffer ; return ; start_com call rx_loop ; wait and read from RS232 call clear_rcif call rx_loop2 ; tx_loop nop btfss PIR1,TXIF ; xmit buffer empty? goto tx_loop ; no, wait ; movwf TXREG ; goto start_com ; no ; ; RECEIVE CHARACTER FROM RS232 ; rx_loop nop btfss PIR1, RCIF ; check for received data goto rx_loop ; bcf PIR1, RCIF ; movf RCREG,w sublw 'a' btfss STATUS, Z goto rx_loop ; bcf STATUS,Z ; movlw 01h ;If led on RB0 is on, an 'a' has been entered movwf PORTB ; return ; clear_rcif bcf PIR1, RCIF btfsc PIR1, RCIF goto clear_rcif ; movlw 02h ;If led on RB1 is on, a second character has been received movwf PORTB ; return ; rx_loop2 nop btfss PIR1, RCIF ; check for received data goto rx_loop2 ; return ; blink ; Show sign of life by blinking RB0 twice ; movlw 01h movwf PORTB ; call Delay500 ; movlw 00h movwf PORTB ; call Delay500 ; movlw 01h movwf PORTB ; call Delay500 ; movlw 00h movwf PORTB ; return ; Delay500 ; DelayL equ 0x20 ; delay register LOW byte DelayM equ 0x21 ; delay register MID byte DelayH equ 0x22 ; delay register HIGH byte ; clrf DelayL ; /R clear DelayL to 0 clrf DelayM ; clear DelayM to 0 movlw 6h ; set DelayH to 12 movwf DelayH Wait1 decfsz DelayL ; subtract 1 from DelayL goto Wait1 ; if not 0, goto Wait1 decfsz DelayM ; subtract 1 from DelayM goto Wait1 ; if not 0, goto Wait1 decfsz DelayH ; subtract 1 from DelayH goto Wait1 ; if not 0, goto Wait1 ; return ; end -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu