8-11
TIMER/COUNTERS AND WATCHDOG TIMER
Timer 2 provides the following operating modes: capture mode, auto-reload mode, baud rate gen-
erator mode, and programmable clock-out mode. Select the operating mode with T2MOD and
TCON register bits as shown in Table 8-3 on page 8-15. Auto-reload is the default mode. Setting
RCLK and/or TCLK selects the baud rate generator mode.
Timer 2 operation is similar to timer 0 and timer 1. C/T2# selects F
OSC
/12 (timer operation) or
external pin T2 (counter operation) as the timer register input. Setting TF2 allows TL2 to be in-
cremented by the selected input.
The operating modes are described in the following paragraphs. Block diagrams in Figures 8-7
through 8-10 show the timer 2 configuration for each mode.
8.6.1 Capture Mode
In the capture mode, timer 2 functions as a 16-bit timer or counter (Figure 8-7). An overflow con-
dition sets bit TF2, which you can use to request an interrupt. Setting the external enable bit
EXEN2 allows the RCAP2H and RCAP2L registers to capture the current value in timer registers
TH2 and TL2 in response to a 1-to-0 transition at external input T2EX. The transition at T2EX
also sets bit EXF2 in T2CON. The EXF2 bit, like TF2, can generate an interrupt.
Figure 8-7. Timer 2: Capture Mode
Interrupt
Request
T2EX
TF2
12
T2
Overflow
RCAP2H
TR2
RCAP2L
TH2
(8 Bits)
EXEN2
EXF2
Capture
A4113-02
XTAL1
C/T2#
0
1
TL2
(8 Bits)