PIC Timer0

Sensacell

Joined Jun 19, 2012
3,432
The timer0 control register T0CON has a bit, TMR0ON, just clear it to turn the timer off.

(EDIT- I stand corrected, I assumed that the TIMER0 module would be the same across parts)
 
Last edited:

t06afre

Joined May 11, 2009
5,934
The timer0 control register T0CON has a bit, TMR0ON, just clear it to turn the timer off.
Have you checked the datasheet before writing this:rolleyes: Look at
TABLE 5-1: SUMMARY OF REGISTERS ASSOCIATED WITH TIMER0. Then you will find that it is no way to enable/disable Timer0 in the 16F887. You may find such a bit in other PICs but not in this one. I do that mistake now and then my self. Assuming that since register/bit is in one PIC you may find it in others PICs to
 

Alec_t

Joined Sep 17, 2013
14,280
Just set the TOCS bit of the OPTION register to 1. That reconfigures the Timer0 module as a counter. Don't clock the TOCK1 pin.
Here's what the datasheet says:
When used as a counter, the Timer0 module will increment on every rising or falling edge of the T0CKI pin. The incrementing edge is determined by the T0SE bit of the OPTION register. Counter mode is selected by setting the T0CS bit of the OPTION register to ‘1’.
Edit: IMO Table 5-1 should show bits 4 and 5 of the OPTION reg shaded.
 
Last edited:
Top