User’s Manual
6-23
05.99
On-Chip Peripheral Components
C513AO
6.2.2 Timer/Counter 2
Timer 2 is a 16-bit timer/counter and has three operating modes:
• 16-bit auto-reload mode (up or down counting)
• 16-bit capture mode
• Baudrate generator (see Section 6.3.3 “Baudrates”)
The modes are selected by bits in the SFR T2CON as shown in Table 6-3:
Timer 2 consists of two 8-bit registers, TH2 and TL2. In the timer function, the TL2 register is
incremented every machine cycle. Since a machine cycle consists of twelve oscillator periods, the
count rate is 1/12th of the oscillator frequency.
In the counter function, the register is incremented in response to a 1-to-0 transition at its
corresponding external input pin, T2 (P1.0). In this function, the external input is sampled during
S5P2 of every machine cycle. When the samples show a high level in one cycle and a low level in
the next cycle, the count is incremented. The new value appears in the register during S3P1 of the
cycle following the one in which the transition was detected. As two machine cycles are required to
recognize a 1-to-0 transition, the maximum count rate is 1/24th of the oscillator frequency. To
ensure that a given level is sampled at least once before it changes, it should be held for at least
one full machine cycle.
Table 6-3
Timer/Counter 2 - Operating Modes
RCLK + TCLK
CP/RL2
TR2
Mode
0
0
1
16-bit auto-reload
0
1
1
16-bit capture
1
X
1
Baudrate generator
X
X
0
(OFF)