MOTOROLA
11-8
PULSE ACCUMULATOR
M68HC11
REFERENCE MANUAL
called gated time accumulation mode because the PACNT can be used to accumulate
the total time the pin was active over a series of pulses. Each time the PAI pin goes to
the chosen active level, the PACNT continues to count from where it left off at the end
of the previous pulse.
A more common use of gated time accumulation mode is to measure the duration of
single pulses (pulse-width measurement). Since this counter does not start counting
until the input signal becomes active, pulse-width measurement is done a little differ-
ently than it would be with a main timer input capture. With the pulse accumulator, the
counter is set to zero before the pulse starts, and the resulting pulse time is directly
read when the pulse is finished; whereas, with input capture, it is necessary to capture
a starting count and an ending count and subtract.
Separate maskable interrupts are generated at counter overflow and at the trailing
edge of the counter enable signal on the PAI pin. The overflow interrupt is useful for
generating interrupts after a specific time delay from when the pin became active or
for measuring signals longer than the range of the 8-bit counter. The PAI pin-related
interrupt is useful for signaling the end of a timing period; software can then be used
to see how long the input was active. These two interrupts can be used together to
create a pulse-width discriminator — for example, write the counter to a value that
would cause an overflow interrupt half way between the time of the shorter pulse width
and the longer pulse width. If the overflow triggers before the PAI pin interrupt, the
pulse is the longer size. If the pin interrupt triggers before the overflow interrupt, the
pulse is the shorter size. If the pulse widths are longer than the range of the 8-bit
counter, incorporate a software overflow counter into the overflow service routine and
use the timeout of this software count, instead of the first PAOVF interrupt, to discrim-
inate between pulse durations.
11.3.1 Measuring Times Longer Than the Range of the 8-Bit Counter
Extending the timing range is done in much the same way as it is for input captures.
Because the pulse accumulator is 8-bits rather than 16-bits, overflows happen more
often. As long as the input signal is active, the user would count overflows. The PAI
pin interrupt indicates when the pulse ends (by setting the PAIF status bit and option-
ally generating an interrupt). The period of the pulse will be
(256 N + PACNT) x (64 E periods/count)
where:
N equals the number of overflows
PACNT equals the final count in the 8-bit pulse accumulator counter
The problems associated with overflows, which occur near input capture edges in the
main timer, are not present in the pulse accumulator. Since the PACNT is not running
before the leading edge of the pulse, there is no potential confusion about an overflow
near this edge. At the trailing edge of the pulse, the PACNT also stops so any pending
overflow will count in the total. The PAOVF interrupt is higher priority than the PAIF
interrupt; therefore, a just-in-time overflow will always be serviced before servicing the