hi , I'm receiving serial UART on an 876A using the following code. The reception is okay.
I tried to implement a software timeout whereby if no data is received after X us, retransmit occurs. If timeout occurs a second time, program goes to error loop and stays there.
The code is as follows:
however, the code always jumps to error_occured routine regardless of whether bytes are received in time or not and I can't simulate UART in MPLAB to debug=(
So I need to ask, Is my implementation correct?
Thanks
Code:
SerialRcv:
BANK0
btfss PIR1,RCIF
goto SerialRcv
MOVF RCREG,w
RETURN
I tried to implement a software timeout whereby if no data is received after X us, retransmit occurs. If timeout occurs a second time, program goes to error loop and stays there.
The code is as follows:
Code:
;;;;;;;;;SERIAL RECEIVE;;;;;;;;;;;;;;;;;;;;
SerialRcv:
keepwaiting:
btfsc PIR1,RCIF
goto bytercvd
bytenotrcvd:
decfsz timecommdelay,f ;timecommdelay set arbitrarily as 1000us
goto keepwaiting
btfss flags,0
goto onemoretime
goto error_occured
onemoretime:
bsf flags,0
goto ATagain
bytercvd:
movf RCREG,w
goback: RETURN
however, the code always jumps to error_occured routine regardless of whether bytes are received in time or not and I can't simulate UART in MPLAB to debug=(
So I need to ask, Is my implementation correct?
Thanks