ok this is simple, I will have a 'packets' of 16 bytes sent over uart @9600 baud, then a gap of about 4mS will indicate the start of a new packet.
I am trying to detect said gap between packets with a small loop involving TMR0, a file that decrements, and PIR1,RCIF. For some reason, I am struggling, not to detect the gap, but actually for the pic to acknowledge within the loop, any reception of serial data at all.
So you might ask if I have set UART Rx up properly. Well, I think so. To test this, I have put the following line above my bit of looped code to ensure I have set the port up correctly:
So yes we do get past the point above, and if it demonstrates anything at all, it should be true that the routine below loops back to 'WaitDTA' to reset the timing loop.
Extra info, baud is correct, I am not getting frame or other error, and I moved to 20Mhz external xtal to eliminate errors but at 9600 really?
I hope this makes some sort of sense, the code is below.
And below you can see the data out (for this test I have removed the gaps so that there is no break in data) along with the 15mS gap highlighted, where just the red LED (D2) is illuminated, then we get to the point where the red & green LED's are illuminated (D2&3). D0 is the serial data on RC7/RX/DT pin.
You can see there are at least 3 instances of serial data that should result in the code going back to 'WaitDTA'..?
This is driving me mad and I suspect it will be something stupid!
I am trying to detect said gap between packets with a small loop involving TMR0, a file that decrements, and PIR1,RCIF. For some reason, I am struggling, not to detect the gap, but actually for the pic to acknowledge within the loop, any reception of serial data at all.
So you might ask if I have set UART Rx up properly. Well, I think so. To test this, I have put the following line above my bit of looped code to ensure I have set the port up correctly:
Code:
btfss PIR1,RCIF ;Any data recieved?
goto $-1
movf RCREG,w ;TEST
call ERCHK ;tests for overrun and framing
Extra info, baud is correct, I am not getting frame or other error, and I moved to 20Mhz external xtal to eliminate errors but at 9600 really?
I hope this makes some sort of sense, the code is below.
Code:
btfss PIR1,RCIF ;Any data recieved?
goto $-1
movf RCREG,w ;TEST
call ERCHK
call DLY500mS
WaitDTA:
movf RCREG,w
call ERCHK
banksel PORTA
bcf PORTC,RED
bcf PORTC,GRN
clrf flgs ;???
movlw d'146' ;Confirmed 15mS (1/8x10^6)/4/256/2/60
movwf TMR0CNT ;Our tmr1 count variable
clrf TMR0
bcf INTCON,T0IF
movf RCREG,w
call ERCHK
btfsc flgs,7
goto Uerror
btfsc flgs,6
goto Uerror
bsf PORTC,RED
bcf PORTC,GRN
TMRLP:
btfss INTCON,T0IF ;every 250uS we will test TMR1, and hence check for comms
goto $-1
bcf INTCON,T0IF
decfsz TMR0CNT,f
goto TMRLP
btfsc PIR1,RCIF ;Any data recieved?
goto WaitDTA ;Back round to next 250uS poll
bsf PORTC,RED
bsf PORTC,GRN ;<<< ROUTINE GETS HERE despite it breaking the 15mS timer!!!
You can see there are at least 3 instances of serial data that should result in the code going back to 'WaitDTA'..?
This is driving me mad and I suspect it will be something stupid!