XC2200 Derivatives
System Units (Vol. 1 of 2)
Interrupt and Trap Functions
User’s Manual
5-47
V2.1, 2008-08
ICU_X2K, V2.2
System Request 0 Trap (A)
Whenever a high-to-low transition on the respective CPU-input is detected (i.e. the
defined condition has become true), the SR0 flag in register TFR is set and the CPU will
enter the SR0 trap routine.
Stack Overflow Trap (A)
Whenever the stack pointer is implicitly decremented and the stack pointer is equal to
the value in the stack overflow register STKOV, the STKOF flag in register TFR is set
and the CPU will enter the stack overflow trap routine.
For recovery from stack overflow, it must be ensured that there is enough excess space
on the stack to save the current system state twice (PSW, IP, in segmented mode also
CSP). Otherwise, a system reset should be generated.
Stack Underflow Trap (A)
Whenever the stack pointer is implicitly incremented and the stack pointer is equal to the
value in the stack underflow register STKUN, the STKUF flag is set in register TFR and
the CPU will enter the stack underflow trap routine.
Software Break Trap (A)
When the instruction currently being executed by the CPU is a SBRK instruction, the
SOFTBRK flag is set in register TFR and the CPU enters the software break debug
routine. The flag generation of the software break instruction can be disabled by the On-
chip Emulation Module. In this case, the instruction only breaks the instruction flow and
signals this event to the debugger, the flag is not set and the trap will not be executed.
System Request 1 Trap (B)
Whenever a high-to-low transition on the respective CPU-input is detected (i.e. the
defined condition has become true), the SR1 flag in register TFR is set and the CPU will
enter the SR1 trap routine.
Undefined Opcode Trap (B)
When the instruction currently decoded by the CPU does not contain a valid XC2200
opcode, the UNDOPC flag is set in register TFR and the CPU enters the undefined
opcode trap routine. The instruction that causes the undefined opcode trap is executed
as a NOP.
This can be used to emulate unimplemented instructions. The trap service routine can
examine the faulting instruction to decode operands for unimplemented opcodes based
on the stacked IP. In order to resume processing, the stacked IP value must be
incremented by the size of the undefined instruction, which is determined by the user,
before a RETI instruction is executed.