AN202
V1.0 | Page 52/73
www.cmostek.com
9 Timer0
9.1
Timer0 Introduction
The timer0 is 8-bit and can be configured as the counter or the timer. When it is configured as the external
event (T0CKI) counter, it can count at the rising edge or the falling edge. When it is configured as the timer,
the counting clock is 2 frequency division of the system clock, which is, it increases once in each instruction
cycle. There is an 8-bit prescaler shared with WDT. When the PSA bit is 0, the prescaler is assigned to the
timer0.
Note: When the value of PSA is changed, the hardware will automatically clear the prescaler.
WDT
Set flag bit
T0IF
On overflow
P
S
A
WDTPS<3:0>
16-bit
Prescaler
8bit
WDT
Time-out
T0CKI
T0SE
T0CS
WDTE
32K
INTOSC
8-bit
Prescaler
8bit
PSA<2:0>
P
S
A
P
S
A
Sync 2
Cycles
TMR0
Data Bus
8 bit
Figure 9-1. Watchdog and Timer0 Diagram
9.2
Timer0 Timer Mode
In this mode, the timer0 adds 1 (without prescaler) in each instruction cycle. The software can clear the T0CS
bit of the OPTION register to enter the timer mode.When the software writes to TMR0, the timer does not
increase progressively in the following 2 cycles.
9.3
Timer0 Counter Mode
In this mode, the timer0 adds 1 when it is triggered by the rising or falling edge of each T0CKI pin (without