"WEBB,TIM (A-Sonoma,ex1)" wrote: > > 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! Try this. It should turn a LED, connected to RB0, on when 'A' is received. Title "RS232 Port" ; list p=16f877, c=140 ; processor type errorlevel -(305) #include "p16f877.inc" DelayL equ 0x20 ; delay register LOW byte DelayM equ 0x21 ; delay register MID byte DelayH equ 0x22 ; delay register HIGH byte ; ; 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: ; Start clrf PORTA clrf PORTB movlw b'01000000' ; TX = Hi movwf PORTC clrf PORTD clrf PORTE bsf STATUS,RP0 clrf TRISA clrf TRISB movlw b'10000000' ; RX = In movwf TRISC clrf TRISD clrf TRISE bcf STATUS,RP0 ; ; ----------------------- ; DISABLE THE COMPARATORS ; ----------------------- ; movlw b'00000111' ; disable comparators movwf CMCON ; ; ------------------------------------ ; SET BAUD RATE TO COMMUNICATE WITH PC ; ------------------------------------ ; Boot Baud Rate = 9600, No Parity, 1 Stop Bit ; bsf STATUS,RP0 movlw d'129' ; 9600 baud movwf SPBRG movlw b'00100100' ; brgh = high (2) movwf TXSTA ; enable Async Trans, Hi brgh movlw b'10010000' ; enable Async Reception clrf STATUS ; RAM Page 0 movwf RCSTA call Delay500 ; startup stabilize delay MnLoop call Receive xorlw 'A' btfss STATUS,Z goto No_A bsf PORTB,0 ; 'A' received movwf TXREG call TransWt goto MnLoop No_A bcf PORTB,0 ; no 'A' received goto MnLoop ; ; ------------------------------------ ; WAIT UNTIL RS232 IS FINISHED SENDING ; ------------------------------------ ; TransWt bsf STATUS,RP0 WtHere btfss TXSTA,TRMT ; transmission is complete if hi goto WtHere bcf STATUS,RP0 ; RAM Page 0 return ; ; ---------------------------------------- ; RECEIVE CHARACTER FROM RS232 OR INTERNAL ; ---------------------------------------- ; This routine does not return until a character is received. Receive nop btfss PIR1,RCIF ; check for received data goto Receive movf RCREG,W movwf RxHold ; tempstore data return ; ; ----------- ; 500Ms DELAY ; ----------- ; Delay500 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 -- Best regards Tony mICros http://www.bubblesoftonline.com mailto:sales@bubblesoftonline.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu