
MOTOROLA
10-2
MAIN TIMER AND REAL-TIME INTERRUPT
M68HC11
REFERENCE MANUAL
wide range of applications although it is not as efficient as dedicated hardware for
some specific timing applications.
10.1.1 Overall Timer Block Diagram
Figure 10-1
is an overall block diagram of the main timer system. It will be helpful to
refer to this figure as the detailed explanations of the various control registers and bits
are discussed in the remainder of this section, which helps put these details in context
with the overall timer system.
The port A pin control block includes logic for timer functions and for general-purpose
I/O. For pins PA0, PA1, and PA2, this block contains edge-detection logic as well as
control logic that allows the user to select which edges will trigger an input capture.
The digital level on these pins can be read at any time (read PORTA register) even if
the pin is being used for the input-capture function. Pins PA[6:3] are used for general-
purpose output or as output-compare pins. When one of these pins is being used for
an output-compare function, it cannot be written directly as if it were a general-purpose
output. Each of the output-compare functions (OC[5:2]) is related to one of the port A
output pins. Output compare one (OC1) has extra control logic, allowing it to optionally
control any combination of the PA[7:3] pins. This extra logic is presented in
10.4.2 Ad-
vanced I/O Pin Control Using OC1
. The PA7 pin can be used as a general-purpose
I/O pin, as an input to the pulse accumulator, or as an OC1 output pin.
The timer functions of these pins are discussed in detail throughout this section. In
some cases, a user may need more detailed information about the logic associated
with these pins, especially when part of port A is being used for timer I/O and the rest
is being used for general-purpose I/O. The best source for such details appears in
7.3.1 Port A
, which includes complete logic diagrams for all of the port A pins.
10.1.2 Input-Capture Concept
The input-capture function is a fundamental element of the timer architecture of the
MC68HC11A8. For the MCU, physical time is represented by the count in the 16-bit
free-running counter. This counter is the central element in the main timer system. In-
put-capture functions, used to record the time at which some external event occurred,
are accomplished by latching the contents of the free-running counter when a selected
edge is detected at the related timer input pin. The time at which the event occurred is
saved in the input capture register (16-bit latch); therefore, although it may take an un-
determined variable amount of time to respond to the event, software can tell exactly
when the event occurred.
By recording the times for successive edges on an incoming signal, software can de-
termine the period and/or pulse width of the signal. To measure a period, two succes-
sive edges of the same polarity are captured. To measure a pulse width, twoalternate
polarity edges are captured. For example, to measure the pulse width for a high-going
pulse, the user would capture at a rising edge and subtract this time from the time cap-
tured for the subsequent falling edge. When the period or pulse width is less than a full
16-bit counter overflow period, the measurement is very straightforward. In practice,
software usually has to keep track of the overflows of the 16-bit counter to extend its