M68HC11
REFERENCE MANUAL
MAIN TIMER AND REAL-TIME INTERRUPT
MOTOROLA
10-21
thing other than initialization and interrupt service routines.
This example is intended to run on an M68HC11EVB evaluation board; thus, the inter-
rupt vector will be treated in a somewhat unusual way. The actual interrupt vector for
input capture 1 is at $FFEE and $FFEF, which is in the monitor program EPROM on
the EVB board. To allow use of these vectors, they have been initialized to point at
specific RAM locations called pseudo-vectors. To use a vector, put a jump (JMP) in-
struction to the address of the interrupt service routine at the RAM pseudo-vector lo-
cations ($00E8, E9, and EA for timer input-capture 1).
In a normal application, the address of the service routine would be hard coded into
the double-byte vector location rather than writing a jump instruction into RAM during
initialization. For additional information about interrupts, see
SECTION 5 RESETS
AND INTERRUPTS
.
The partial listing shown in
Figure 10-6
depicts the important parts of the pulse-width
measurement illustrated in Example 10–2.
A detailed timing analysis for Example 10–2 is shown in
Figure 10-7
. Unlike the pre-
vious example, interrupt latencies must be considered to determine the minimum
pulse width that can be measured by this program. The instructions in the main pro-
gram do not affect the minimum measurable pulse except that the execution time of
the longest instruction executing at the time of the interrupt determines the longest
possible latency from an input-capture edge to when it can be serviced. The interrupt
operation does not begin until the currently executing instruction is completed. If the
pulse width being measured is too short, the second edge can come before the pro-
gram is ready for it. This time will determine the shortest pulse that can be measured
with this example program. As in the previous example, if the signal being measured
is longer than the range of the 16-bit timer counter, then two pulse widths, which were
different by an exact multiple of the overflow period, are not distinguishable. Since this
program does not consider overflows, the overflow period of the 16-bit timer will deter-
mine the longest pulse that can be measured correctly with this program. These limi-
tations are program limits and, as shown in other examples, the input-capture
functions can be used to measure much shorter or much longer times.
As shown in Example 10–2, the CPU repeats the WAITL2 loop continuously, waiting
for the first rising edge. Since the edge is asynchronous to the program execution,
where the edge will occur relative to this program is uncertain. This uncertainty leads
to a best-case and a worst-case minimum period that can be measured by this pro-
gram. The worst case arises when the first edge is not recognized before the end of
the BEQ WAITL2 instruction at [1]. In this worst case, the LDAA IC1DUN instruction
would have to finish, which causes an extra four-cycle delay. The best case arises
when the edge is recognized just before the end of an instruction in the main program.
In this best case, interrupt processing starts almost immediately. A more obscure pos-
sibility would exist if there were other lower priority interrupts enabled in the system.
In that case, a lower priority interrupt could initiate stacking leading to the interrupt. The
priority resolution to decide which vector to take does not occur until the stacking op-
erations are finished. If the IC1 edge is recognized before the condition code register
(CCR) is stacked, it will be serviced rather than the lower priority interrupt that started