|
C501_1 Datasheet, PDF (69/121 Pages) Siemens Semiconductor Group – 8-Bit Single-Chip Microcontroller | |||
|
◁ |
On-Chip Peripheral Components
C501
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. Normally, as a timer it would increment every machine
cycle (thus at fOSC/12). As a baud rate generator, however, it increments every state time (fOSC/2). In
that case the baud rate is given by the formula
Modes 1,3 baud rate = fOSC/32Ã[65536 â (RC2H, RC2L)]
where (RC2H, RC2L) is the content of RC2H and RC2L taken as a 16-bit unsigned integer.
Note that the rollover in TH2 does not set TF2, and will not generate an interrupt. Therefore, the
timer 2 interrupt does not have to be disabled when timer 2 is in the baud rate generator mode. Note
too, that if EXEN2 is set, a 1-to-0 transition in T2EX can be used as an extra external interrupt, if
desired.
It should be noted that when timer 2 is running (TR2 = 1) in âtimerâ function in the baud rate
generator mode, one should not try to read or write TH2 or TL2. Under these conditions the timer
is being incremented every state time, and the results of a read or write may not be accurate. The
RC registers may be read, but shouldnât be written to, because a write might overlap a reload and
cause write and/or reload errors. Turn the timer off (clear TR2) before accessing the timer 2 or RC
registers, in this case.
Semiconductor Group
6-35
|
▷ |