M68HC11
REFERENCE MANUAL
MAIN TIMER AND REAL-TIME INTERRUPT
MOTOROLA
10-29
MC68HC11A8 (OC1) can control any combination of the five timer output pins even if
another output compare is already controlling the pin(s). The value and implications of
this feature will be explained in greater detail.
For OC[5:2], a pair of control bits in the timer control register 1 (TCTL1) control the au-
tomatic action that will occur at the respective timer output pin when an output com-
pare happens (16-bit OCx register matches the free-running timer). The control bit
pairs (OMx, OLx, x = 2, 3, 4, or 5) are encoded to allow the four following possibilities:
1) timer output compare causes no pin change; 2) toggle pin on each successful com-
pare; 3) force pin to zero on a successful compare; and 4) force pin to one on a suc-
cessful compare. Each of the output compares (OC[5:2]) is associated with a separate
port A pin, and the automatic pin actions for each output compare are independently
controlled.
For OC1, the automatic pin actions are controlled by the OC1 mask (OC1M) and OC1
data (OC1D) registers. The OC1M register specifies which port A pins are to be affect-
ed by OC1. The OC1D register specifies the data to be sent to the affected port A
pin(s) when there is a successful OC1 match. If OC1 and another output compare are
both controlling the same pin and if both attempt to change the pin simultaneously,
OC1 will have priority.
Output pins for the five output-compare functions can be used as general-purpose out-
put pins having nothing to do with the timer system or as timer outputs directly con-
trolled by the timer system. When one of these pins is configured for timer use, it
cannot be written directly from software as a general-purpose port A output line. If the
user needs to change a timer output pin without waiting for an actual output compare,
the force output-compare function can be used. This function may be used to initialize
the state of timer outputs or to force an output change before it was scheduled to occur
by the associated output-compare register. Another way to change the state of a timer
output pin is to temporarily disengage the timer by changing the timer control registers.
This method requires a more detailed understanding of the actual port A pin logic. De-
tailed schematics of the port A output pins are shown and explained in
SECTION 7
PARALLEL INPUT/OUTPUT
.
The 16-bit output-compare register for each output-compare function can be read or
written by software as a pair of 8-bit registers. The TOCx registers are forced to $FFFF
during reset.
A write to the high-order byte of an output-compare register pair inhibits the output-
compare function for one bus cycle. This inhibit prevents erroneous comparisons us-
ing a 16-bit value whose high-order half was just written and whose low-order half still
contains data from the previous output-compare value. Consider the case where an
output-compare register is $FF0F and the user tries to write it to $00FF as the free-
running timer is counting through the value $000F. Without the one-cycle inhibit after
writing to the upper half of the output-compare register, an erroneous compare could
occur at $000F. As long as the user utilizes a double-byte write instruction, such as
store D (STD), to update output-compare registers, this one-cycle inhibit mechanism
will assure that no unintentional compares will result after the write of the high-order
half but before the write of the low-order half.