English
Language : 

UPSD3422_06 Datasheet, PDF (95/293 Pages) STMicroelectronics – Turbo Plus Series Fast Turbo 8032 MCU with USB and Programmable Logic
uPSD34xx
Standard 8032 timer/counters
The timer can be configured for either “timer” or “counter” operation. In the most typical
applications, it is configured for “timer” operation (C/T2 = 0). “Timer” operation is a little
different for Timer 2 when it's being used as a baud rate generator. In this case, the baud
rate is given by the formula:
UART Mode 1,3 Baud Rate =fOSC/(32 x [65536 – [RCAP2H, RCAP2L]))
where [RCAP2H, RCAP2L] is the content of the SFRs RCAP2H and RCAP2L taken as a
16-bit unsigned integer.
A roll-over in TH2 does not set TF2, and will not generate an interrupt. Therefore, the Timer
Interrupt does not have to be disabled when Timer 2 is in the Baud Rate Generator Mode.
If EXEN2 is set, a 1-to-0 transition on pin T2X will set the Timer 2 interrupt flag EXF2, but
will not cause a reload from RCAP2H and RCAP2L to TH2 and TL2. Thus when Timer 2 is
in use as a baud rate generator, the pin T2X can be used as an extra external interrupt, if
desired.
When Timer 2 is running (TR2 = 1) in a “timer” function in the Baud Rate Generator Mode,
firmware should not read or write TH2 or TL2. Under these conditions the results of a read
or write may not be accurate. However, SFRs RCAP2H and RCAP2L may be read, but
should not be written, because a write might overlap a reload and cause write and/or reload
errors. Timer 2 should be turned off (clear TR2) before accessing Timer 2 or Registers
RCAP2H and RCAP2L, in this case.
Table 45 on page 96 shows commonly used baud rates and how they can be obtained from
Timer 2, with T2CON = 34h.
95/293