C.2.8.2 16-Bit Timer/Counter Mode
Figure C-4. illustrates how Timer 2 operates in timer/counter mode with the optional capture
feature. The C/T2 bit determines whether the 16-bit counter counts CLK24 cycles (divided by
4 or 12), or high-to-low transitions on the T2 pin. The TR2 bit enables the counter. When the
count increments from FFFFh, the TF2 flag is set, and the T2OUT pin goes high for one
CLK24 cycle.
Table C-6. T2CON Register - SFR C8h
Bit
Function
T2CON.7
TF2 - Timer 2 overflow flag. Hardware will set TF2 when
the Timer 2 overflows from FFFFh. TF2 must be cleared to 0
by the software. TF2 will only be set to a 1 if RCLK and
TCLK are both cleared to 0. Writing a 1 to TF2 forces a
Timer 2 interrupt if enabled.
T2CON.6
T2CON.5
T2CON.4
T2CON.3
EXF2 - Timer 2 external flag. Hardware will set EXF2 when
a reload or capture is caused by a high-to-low transition on
the T2EX pin, and EXEN2 is set. EXF2 must be cleared to 0
by the software. Writing a 1 to EXF2 forces a Timer 2
interrupt if enabled.
RCLK - Receive clock flag. Determines whether Timer 1 or
Timer 2 is used for Serial Port 0 timing of received data in
serial mode 1 or 3. RCLK =1 selects Timer 2 overflow as the
receive clock. RCLK =0 selects Timer 1 overflow as the
receive clock.
TCLK - Transmit clock flag. Determines whether Timer 1 or
Timer 2 is used for Serial Port 0 timing of transmit data in
serial mode 1 or 3. RCLK =1 selects Timer 2 overflow as the
transmit clock. RCLK =0 selects Timer 1 overflow as the
transmit clock.
EXEN2 - Timer 2 external enable. EXEN2 = 1 enables
capture or reload to occur as a result of a high-to-low
transition on the T2EX pin, if Timer 2 is not generating baud
rates for the serial port. EXEN2 = 0 causes Timer 2 to ignore
all external events on the T2EX pin.
T2CON.2
T2CON.1
TR2 - Timer 2 run control flag. TR2 = 1 starts Timer 2. TR2
= 0 stops Timer 2.
C/T2 - Counter/timer select. C/T2 = 0 selects a timer
function for Timer 2. C/T2 = 1 selects a counter of falling
transitions on the T2 pin. When used as a timer, Timer 2 runs
at 4 clocks per tick or 12 clocks per tick as programmed by
CKCON.5, in all modes except baud rate generator mode.
When used in baud rate generator mode, Timer 2 runs at 2
clocks per tick, independent of the state of CKCON.5.
C - 10
Appendix C: 8051 Hardware Description
EZ-USB TRM v1.9