TMR0 PS =1:16,4Mhz XT
movlw 20h
movwf FSR
;---------------------------------------------------------
;ignore the start pulse & wait for next mark pulse present
;---------------------------------------------------------
;----code here to---
;-----ignore the----
;-----start bit-----
;mark detected
;------------------------------------------------
;Measure the mark time length until space detect
;------------------------------------------------
DO_Mark
call Start_T ;turn on the TMR0
btfsc INTCON,T0IF ;see if the mark time too long?
goto Invalid ;256X16 = 4096 ??
btfss GPIO,GP2 ;wait for space pulse
goto $-3 ;no,still mark time then go back
;yes,space detected
movf TMR0,W
movwf INDF ;save the mark time
incf FSR,F
;------------------------------------------------
;Measure the space time length until mark detect
;------------------------------------------------
DO_Space
call Start_T
btfsc INTCON,T0IF ;see if the space time too long?
goto Invalid ;256X16 = 4096 ??
btfsc GPIO,GP2 ;wait for mark pulse
goto $-3 ;no,still space time then go back
;yes,mark detected
movf TMR0,W
movwf INDF ;save the space time
incf FSR,F
goto DO_Mark ;
Start_T clrf TMR0 ;reset TMR0
bcf INTCON,T0IF ;
return
Invalid goto Somewhere ;packet expires
;result registers from 20h-30h
==============================
112H
55L
55H
55L
55H
112L
112H
112L
55H
55L
55H
55L
112H
112L
112H
112L
55H