English
Language : 

DS80C320-MCG Datasheet, PDF (121/175 Pages) Dallas Semiconductor – High-Speed Microcontroller User Guide
High-Speed Microcontroller User’s Guide
SECTION 11: PROGRAMMABLE TIMERS
All members of the High-Speed Microcontroller family incorporate three 16-bit programmable timers and
some also have a Watchdog Timer with a programmable interval. Because the Watchdog Timer is
significantly different from the other timers, it is described separately. The 16-bit Timers are referred to
simply as timers.
In most modes, the timers can be used as either counters of external events or timers. When functioning
as a counter, 1 to 0 transitions on a port pin are monitored and counted. When functioning as timers, they
effectively count oscillator cycles. The time base for the timer function is the main oscillator clock
divided by either 4 or 12. This selection is described below. Because each clock pulse must be sampled
high for one machine cycle and low for one machine cycle to be recognized, this sets the maximum
sampling frequency on any timer input at 1/8 of the main oscillator frequency.
The three timers are compatible with the 80C32. That is, they offer the same controls and I/O functions
that were available in the 80C32. As mentioned above, the actual timing of these functions is user
selectable to be compatible with the machine cycle of the older generation of 8051 family (12 clocks per
tick) or the new generation (4 clocks per tick). The timing for each of the three timers can be selected
independently and can be changed dynamically. Each timer has 4 primary modes as discussed below.
The Watchdog Timer Reset provides CPU monitoring by requiring software to clear the timer before the
user selected interval expires. If the Timer is not cleared, the CPU will be reset by the Watchdog. The
Watchdog function is optional and is described below. Since the High-Speed Microcontroller timers have
a variety of features, the following summary table shows the capabilities.
Timer 0
Timer 1
13–bit Timer/counter
13–bit Timer/counter
16–bit Timer/counter
16–bit Timer/counter
8–bit Timer w/ Auto–reload
8–bit Timer w/ Auto–reload
Two 8–bit Timer/counters
External control pulse timer/counter
External control pulse timer/counter Baud rate generator
Timer 2
16–bit Timer/counter
16–bit Timer with capture
16–bit Auto–reload Timer/counter
16–bit up/down auto–reload
Timer/counter
Baud rate generator
Timer output clock generator
16-BIT TIMERS
Timers 0 and 1 are nearly identical. Timer 2 has several additional features such as up/down counting,
capture values and an optional output pin that make it unique. Timers 0 and 1 are described first. Timer
2 is described separately. As mentioned above, the time base for each timer can be varied and this is also
discussed in more detail below.
Timer 0 and 1 both have four operating modes. They are 13-bit timer/counter, 16-bit timer/counter, 8-bit
timer/counter with auto-reload, and two 8-bit timers. The latter mode is available to Timer 0 only. These
modes are controlled by the TMOD register. Each timer can also serve as a counter of external pulses (1
to 0 transition) on the corresponding Tn pin. This selection is controlled by the TMOD register. One
other option is to gate the timer/counter using an external control signal. This allows the timer to measure
the pulse width of external signals. Timers 0 and 1 are enabled using the TCON register which is also the
location of their flags. The registers are described below. Following this is a detailed explanation of the
four operating modes.
Each timer consists of a 16-bit register in two bytes. These are called TL0, TH0, TL1, and TH1. As
shown, each timer is broken into low and high bytes. Software can read or write any of these locations at
any time.
121 of 175