Hi Ray, Thank you very much for your help. What you suggested fixed the problem. Now I can move on to the next step. Thank you again. At 01:08 PM 5/4/99 -0400, you wrote: >Hi Aidi, >Just a couple of things, you should set CREN before clearing SREN, >I also found that toggling CREN after receive to clear any rx errors. >See code below. You also must wait for the byte to actually be received. > > >> Hi, >> >>I'm using the code below to receive a byte from the US ART. When I get the >>byte I display it on the LED's and echo it back. >>This code is not working for me. Can anybody tell me what I'm doing wrong. >> Thanks >> >> >> list p=16c74 >> Title "first aidi Program" >> >> include >> >> org 00h >> >>Start >> clrf PORTB ;Clear PORT_B output latches >> >> bsf STATUS,RP0 ;Go to Bank1 >> >> clrf TRISB ;Config PORT_B as all outputs >> >> >> movlw 19h ;Set Band rate (9600 baud @4MHz) >> movwf SPBRG >> movlw b'00100100' ;8-bit transmit, transmitter enable >> movwf TXSTA ;Asynchronous mode, High baud rate >> >> bcf STATUS,RP0 ;Go to Bank0 >> >> movlw b'10010000' ;8-bit receive, receiver enabled >> movwf RCSTA ;serial port enabled >> > >; ADDED THE FOLLOWING LINES *****; > ; >RxTest ; > ; > BSF RCSTA,4 ;set CREN > BCF RCSTA,5 ;clear SREN > ; >RxWait ; > BTFSS PIR1,5 ;RxBuffer Full when PIR,5=1 > GOTO RxWait ; > ; > BCF RCSTA,4 ;toggle CREN to clear any Rx > BSF RCSTA,4 ;errors. You could choose to > ;handle Rx errors differently > ;for a "real" application. >; *******************************; > >> movf RCREG,W ;Get input data >> movwf PORTB ;Display on LEDs >> movwf TXREG ;Echo character back > >> goto RxTest ; ***Changed here also. >> >> end > >>Aidi Moubhij >> >>aidi@mjr.com > >Hope that helps. > > > >Ray Gardiner ray@hdc.com.au > Aidi Moubhij aidi@mjr.com