Information
2003 Microchip Technology Inc. DS80072D-page 5
PIC16C712/716
2. Module: Timer1
When Timer1 is configured to operate as an
asynchronous counter, care must be taken that
there is no incoming pulse while the module is
being turned off. If an incoming pulse arrives while
Timer1 is being turned off (i.e., TMR1ON transi-
tions from 1 to 0), the value of registers TMR1L
and TMR1H will be unpredictable.
Work around
This solution involves changing Timer1 from
Asynchronous to Synchronous mode before turn-
ing off Timer1. No additional resources are
required for this solution.
Timer1 synchronization will start, effectively stop-
ping Timer1, one Q period after the Synchronous
mode is enabled, or one Q period later than would
have been realized by simply clearing the
TMR1ON bit. One additional count, in excess of
the counts accrued during this extra Q period, may
be accumulated before the TMR1ON bit is eventu-
ally cleared in the next instruction. The occurrence
of this additional count is dependent on the phase
relationship between OSC1, or the internal system
clock, and T1CKI.
Code Example:
**************************************************************************************
; Call this routine to stop Timer1 asynchronous counting
;
; Timer1 is stopped after the timer is changed to synchronous mode
; The captured timer value resides in TMR1H and TMR1L at the completion of this
; routine.
TMR1Capture ; entry point
bcf T1CON,NOT_T1SYNC ; set for synchronous mode
bcf T1CON,TMR1ON ; stop timer
bsf T1CON,NOT_T1SYNC ; restore asynchronous mode
return ; return to calling routine