M68HC11
REFERENCE MANUAL
MAIN TIMER AND REAL-TIME INTERRUPT
MOTOROLA
10-7
The divider chains for the serial peripheral interface (SP[) clock rate and the serial
communications interface (SCI) baud-rate generator are the last two major clock divid-
er chains in the MCU. The 4,064 bus-cycle oscillator startup delay at powerup and af-
ter STOP is derived from the SCI baud-rate counter. Like the main timer divider chain,
this divider is free running and uninterruptable except by special commands available
only in special test modes.
Figure 10-3
, which illustrates all of the major clock divider chains in the
MC68HC11A8, will help the user understand how the timer fits into the overall MCU
system. The main timer counter and its prescaler and derived clock chains for RTI and
COP watchdog are described in more detail in subsequent paragraphs.
10.2.1.1 Prescaler
A programmable prescaler allows the user to select one of four clocking rates to drive
the 16-bit main timer counter. This choice allows the programmer to make a trade-off
between timer resolution and timer range. The default fastest rate causes the main
timer counter to clock at the E-clock rate, which results in a timer resolution of 500 ns
and a timer range of 32.77 ms between overflows (for E = 2 MHz). The slowest rate
(largest prescale factor) causes the main timer counter to clock at an E divided by 16
rate, which results in timer resolution of 8
μ
s and a timer range of 524.3 ms between
overflows (for E = 2 MHz).
The timer range is important because the software needed for timing functions is more
complex if timer overflows must be considered. If time periods are known to be less
than the time between successive overflows, then the overflows can be ignored, and
time periods are calculated using simple 16-bit arithmetic instructions (even if an over-
flow occurs within the timed period). The overflow from 16-bit arithmetic instructions
behaves just like an overflow from the 16-bit counter. To illustrate this point, if the timer
counter is near its maximum count ($FFF0) and an output compare is desired in 100
10
cycles, add $FFF0 plus $0064 (modulo $FFFF) to get $0054 (in base ten modulo
65,536, that would be 65,520 + 100 = 84). Then write this result ($0054) to an output-
compare register. In 100 cycles, the timer counter will have overflowed and counted
up to $0054 where the output compare will occur. When overflow has to be consid-
ered, timing calculations become much more complicated.
Another factor to consider in selecting the prescaler rate is power consumption. Since
CMOS power consumption is directly proportional to its frequency of operation, power
is saved by reducing frequency. The amount of logic driven by the prescaled timer
clock is fairly small compared to the amount of logic driven by the PH2 clock, but some
savings will still result from selecting a slower count rate.
The user should consider resolution needed and the longest time period needed (or
the length of the longest pulse needed). As an example, consider measuring periods
between 10 ms and 100 ms. For an E-clock frequency of 2 MHz, a prescale division
factor of 4 would result in a timing range of 131.1 ms; therefore, overflows could be
ignored in calculations. Since the resolution would be 2
μ
s, an error of one count would
represent an error of 0.02 percent of the shortest expected pulse (10 ms). For most
applications, this accuracy is more than required.