MOTOROLA
5-22
RESETS AND INTERRUPTS
M68HC11
REFERENCE MANUAL
the set nor the clear input to the X bit flip-flop will be activated, and the X bit will remain
unchanged.
The M68HC11 supports a STOP mode where all clocks are stopped to reduce power
consumption to a few microamps. Recovery to active mode is accomplished by a reset
or an interrupt (IRQ or XIRQ). Depending upon the state of the X bit in the CCR, the
XIRQ input offers a choice of two recovery methods. If X is zero, XIRQ interrupts are
enabled, and recovery leads to register stacking and normal interrupt service. If X is
one, XIRQ interrupts are inhibited, but the XIRQ pin can still be used for recovery from
the STOP mode. Rather than resuming operation with service of an interrupt (XIRQ),
the clocks start and processing resumes with the next opcode after the STOP opcode.
This technique can be thought of as a STOP-continue mechanism.
Some M68HC11 MCUs were manufactured with a subtle defect that can cause failure
to properly recover from STOP with an interrupt input (IRQ or XIRQ). If the opcode im-
mediately preceding the STOP opcode came from column 4 or 5 of the opcode map,
recovery was incorrect. Column 4 and 5 opcodes are accumulator instructions, such
as negate A (NEGA) or decrement B (DECB), which seldom appear immediately be-
fore a STOP instruction; therefore, a long time elapsed before the problem was dis-
covered. A simple NOP instruction before the STOP opcode assures proper recovery
from STOP in all cases.
5.4.2 Illegal Opcode Fetch
Since not all possible opcodes or opcode sequences are defined, an illegal opcode de-
tection circuit has been included. When an illegal opcode is detected, an interrupt is
requested to the illegal opcode vector. The illegal opcode vector should never be left
uninitialized. The stack pointer should be re-initialized as a result of an illegal opcode
interrupt so repeated execution of illegal opcodes does not cause stack overruns. If
the illegal opcode vector were left uninitialized, it could point to a memory location that
contained an illegal opcode. In such a case, there would be an infinite loop of repeated
illegal opcodes and an infinite stack overflow, which would cause the register contents
to be stored to all memory addresses in a very short time.
The illegal opcode trap mechanism works for all unimplemented opcodes on all four
opcode-map pages. The address stacked as the return address for the illegal opcode
interrupt is the address of the first byte of the illegal opcode. Otherwise, it would be
almost impossible to determine whether the illegal opcode had been one or two bytes.
The stacked return address can be used as a pointer to the illegal opcode so the illegal
opcode service routine can evaluate the offending opcode.
The illegal opcode mechanism can be used to create a number of special-purpose in-
structions that use otherwise illegal opcodes. When one of these opcodes is encoun-
tered, the interrupt service routine can look up the special opcocde and perform some
special task. The return address would need to be manually changed since it points to
the illegal opcode rather than to the instruction that follows the illegal opcode.
The TEST Instruction (opcode $00) is a legal opcode in special test and bootstrap
modes, but it is an especially offensive illegal opcode in normal operating modes. The