![CMOSTEK CMT2189C User Manualline Download Page 55](http://html1.mh-extra.com/html/cmostek/cmt2189c/cmt2189c_user-manualline_2627489055.webp)
AN202
V1.0 | Page 55/73
www.cmostek.com
10 Timer2
The timer2 is the 8-bit timer, which contains the following functions:
8-bit timer register
8-bit period register
Interrupt on TMR2 match with PR2
Software programmable prescaler(1:1
,
1:4
,
1:16)
Software programmable postscaler(1:1 to 1:16)
Figure 10-1. Timer2 Diagram
Timer2 Operation Principle
The clock input of the Timer2 module is the system instruction clock (FOSC/2).The clock is sent to the Timer2
prescaler, and its prescale rate has three options of 1:1, 1:4 and 1:16. The output of the prescaler is used to
increase the TMR2 register.
The values of TMR2 and PR2 are constantly compared to determine when to match. TMR2 will increase from
00h until it matches PR2. The following two cases will occur when matching:
TMR2 is reset to 0x00 on the next increment cycle.
Timer2 postscale rate increases progressively.
The matching output of comparing Timer2 and PR2 is sent to the Timer2 postscaler.The option range of the
postscaler is from 1:1 to 1:16.The output of the Timer2 postscaler is used to set the interrupt flag bit TMR2IF
of the PIR1 register to 1.
Note:
1. Both TMR2 and PR2 are read-write registers. Their values are initialized to 0 and 0xFF respectively upon
Reset.
2. Setting the TMR2ON bit of the T2CON register to 1 can open Timer2, and conversely clearing the
Prescaler
1:1, 1:4, 1:16
T2CKPS<1:0>
TMR2
Comparator
PR2
Postscaler
1:1 ~ 1:16
TOUTPS<3:0>
EQ
TMR2
Output
Set Flag Bit
TMR2IF