MOTOROLA
10-24
MAIN TIMER AND REAL-TIME INTERRUPT
M68HC11
REFERENCE MANUAL
The earliest place the second edge could occur and be properly handled is during the
cycle after the status flag clear instruction [7], which occurs before returning from the
interrupt service routine after processing the leading edge of the pulse. If the second
edge came before this time, it would still be captured, but the IC1F flag would be
cleared by the clearing instruction intended to clear the flag from the first edge. The
minimum pulse width that can be measured by this program would be the time from
[1] or [2] through [7]. This time is a total of 63 to 67 cycles or about 34
μ
s.
This timing analysis is based on this specific example running by itself in the EVB
board and is not intended to show the smallest pulse that can be measured. Since no
other tasks are being performed in this example, the interrupt latency is somewhat
shorter than it would be in a realistic system. In a normal system, the user would not
have to work through the EVB’s pseudo-vector mechanism and would save three cy-
cles of latency time (because of the JMP in the pseudo-vector locations). Conversely,
in a real system, the user could get this interrupt just as a multiply instruction had start-
ed; thus, there could be a wait of up to 10 cycles (MUL takes 10 cycles) for that instruc-
tion to finish before servicing the input-capture interrupt. Worse yet, the user may have
just started servicing another interrupt source when the edge was recognized; thus,
the input capture would have to wait for that interrupt service routine to be completed
before it could be serviced. A much more detailed discussion of interrupts is presented
in
SECTION 5 RESETS AND INTERRUPTS
. The shortest pulse the user would be
able to measure in a realistic system will be a few hundred cycles rather than the few
dozen cycles shown in this isolated example.
This timing analysis is based on a detailed knowledge of timer logic and instruction tim-
ing. Instruction timing tells which cycle within the instruction actually reads or writes a
register. Instruction details can be found in
APPENDIX A INSTRUCTION SET DE-
TAILS
. Detailed information concerning timer captures is given in
10.5 Timing Details
For The Main Timer System
. Detailed operation of the interrupt mechanism is pre-
sented in
SECTION 5 RESETS AND INTERRUPTS
.
10.3.4 Measuring Very Short Time Periods
Since the MC68HC11A8 has three input-capture functions, it is theoretically possible
to measure pulse widths as short as one timer count by connecting the signal to two
input-capture pins. One input capture is configured to detect the leading edge of the
pulse; whereas, the other is configured to detect the trailing edge. Although this func-
tion is possible, it is not commonly used.
10.3.5 Measuring Long Time Periods with Input Capture and Overflow
There are at least two ways to measure time periods that are longer than the range of
the 16-bit free-running timer. The following paragraphs discuss an example based on
input capture and counting timer overflows, which is accurate to
±
1 timer count (500
ns in this case). If the user were measuring times in the seconds range to a resolution
of
±
100 ms, a software approach might be easier than the input-capture/overflow
method. In the software approach, the user sets up a real-time loop structure where
the main program is executed once each tenth of a second. Other real-time periods
could be used, but a tenth of a second is easier. The user starts a software counter