;
; make the T0CKI pin an output to stop counting after 200-msecs
; (indirect but same as bcf TRISIO,T0CKI)
;
bcf INDF,GP2 ; counter input 'off' (output) |B0
;
; finalize our 32-bit count accumulator
;
; ACCA+0, most significant byte (TMR0 overflows)
; ACCA+1, next significant byte (TMR0 overflows)
; ACCA+2, copy of TMR0 register
; ACCA+3, prescaler, least significant byte
;
movf TMR0,W ; get TMR0 value |B0
movwf ACCA+2 ; put it in our 32 bit count |B0
;
; empty the 1:256 prescaler by toggling the TMR0 edge select
; bit and decrementing ACCA+3 (initially 00) until detecting
; the prescaler overflow into TMR0.
;
Flush bsf STATUS,RP0 ; select Bank 1 |B1
bcf OPTION_REG,T0SE ; clock on rising edge |B1
bsf OPTION_REG,T0SE ; clock on falling edge |B1
bcf STATUS,RP0 ; select Bank 0 |B0
decf ACCA+3,f ; decrement counter LSB |B0
movf TMR0,W ; compare TMR0 to saved value |B0
xorwf ACCA+2,W ; prescaler overflow? |B0
bz Flush ; no, clock it again |B0
;