I am monitoring the NMEA stream from a GPS and need to recognize the $GPGLL header. The scheme I am trying use is to take bytes out of the UART and shift them up through three registers. After each new entry I test for the header pattern.
The problem is that nothing gets shifted through the registers. I use the SWPB instruction elsewhere in my code and it works. Something is wrong with my shift algorithm but I can’t see it. Any ideas?
;-----------------------------------------------------------------------------
; Character stream - every character recieved is entered into a shift
; register that consists of R5 (lo order) through R7 (hi order)
;-----------------------------------------------------------------------------
Char: swpb R7 ; Shift byte 5 to the byte 6 position
swpb R6 ; Move byte 3 to the byte 4 position
mov.b R6, R7 ; Move byte 4 to the byte 5 position
swpb R5 ; Move byte 1 to the byte 2 position
mov.b R5, R6 ; Move byte 2 to the byte 3 position
mov.b R12, R5 ; Insert new byte into position 1
ret