English
Language : 

UPSD33XX Datasheet, PDF (74/231 Pages) STMicroelectronics – Fast 8032 MCU with Programmable Logic
uPSD33xx
Timer 2
Timer 2 can operate as either an event timer or as
an event counter. This is selected by the bit C/T2
in the SFR named, T2CON (Table 41., page 75).
Timer 2 has three operating modes selected by
bits in T2CON, according to Table 42., page 76.
The three modes are:
■ Capture mode
■ Auto re-load mode
■ Baud rate generator mode
Capture Mode. In Capture Mode there are two
options which are selected by the bit EXEN2 in
T2CON. Figure 25., page 79 illustrates Capture
mode.
If EXEN2 = 0, then Timer 2 is a 16-bit timer if C/T2
= 0, or it’s a 16-bit counter if C/T2 = 1, either of
which sets the interrupt flag bit TF2 upon overflow.
If EXEN2 = 1, then Timer 2 still does the above,
but with the added feature that a 1-to-0 transition
at external input pin T2X causes the current value
in the Timer 2 registers, TL2 and TH2, to be cap-
tured into Registers RCAP2L and RCAP2H, re-
spectively. In addition, the transition at T2X
causes interrupt flag bit EXF2 in T2CON to be set.
Either flag TF2 or EXF2 will generate an interrupt
and the MCU must read both flags to determine
the cause. Flags TF2 and EXF2 are not automati-
cally cleared by hardware, so the firmware servic-
ing the interrupt must clear the flag(s) upon exit of
the interrupt service routine.
Auto-reload Mode. In the Auto-reload Mode,
there are again two options, which are selected by
the bit EXEN2 in T2CON. Figure 26., page 79
shows Auto-reload mode.
If EXEN2 = 0, then when Timer 2 counts up and
rolls over from FFFFh it not only sets the interrupt
flag TF2, but also causes the Timer 2 registers to
be reloaded with the 16-bit value contained in
Registers RCAP2L and RCAP2H, which are pre-
set with firmware.
If EXEN2 = 1, then Timer 2 still does the above,
but with the added feature that a 1-to-0 transition
at external input T2X will also trigger the 16-bit re-
load and set the interrupt flag EXF2. Again, firm-
ware servicing the interrupt must read both TF2
and EXF2 to determine the cause, and clear the
flag(s) upon exit.
Note: The uPSD33xx does not support selectable
up/down counting in Auto-reload mode (this fea-
ture was an extension to the original 8032 archi-
tecture).
74/231