First page Back Continue Last page Overview Graphics
16-Bit Free-Running Counter
The primary registers associated with the counter are
- TCNT (TCNTH located at 0x0084 and TCNTL at 0x0085)
- TSCR (located at 0x0086)
- TMSK2 (located at 0x008D)
- TFLG2 (located at 0x008F)
What will we need to know or specify?
- How fast to count and
- When the counter rolls over
Let's look at the timer registers by first asking ourselves what control flags we will need in order to use the counter.
First, we need the counter itself. Since it is 16 bits wide, we need two registers to hold its value. They are TCNTH located at 0x0084 and TCNTL at 0x0085. These registers together are comprise the two-byte counter register TCNT. Note that the higher byte of the counter register has the lower address.
Like the maskable interrupts, the timer can be enabled or disabled. We would disable the timer for a different reason however. Disabling the timer reduces power consumption. The timer is enabled or disabled using the Timer Enable Bit (TEN) of the Timer System Control Register (TSCR) which is located at 0x0086. It can be read or written at any time.