XC2200 Derivatives
System Units (Vol. 1 of 2)
Interrupt and Trap Functions
User’s Manual
5-43
V2.1, 2008-08
ICU_X2K, V2.2
PSW, CSP (in segmentation mode), and IP are pushed on the internal system stack and
the CPU level in register PSW is set to the highest possible priority level (level 15),
disabling all interrupts. The global register bank is selected. Execution branches to the
respective trap vector in the vector table. A trap service routine must be terminated with
the RETI instruction.
The nine hardware trap functions of the XC2200 are divided into two classes:
Class A traps
are:
•
System Request 0 (SR0)
•
Stack Overflow
•
Stack Underflow trap
•
Software Break
These traps share the same trap priority, but have individual vector addresses.
Class B traps
are:
•
System Request 1 (SR1)
•
Undefined Opcode
•
Memory Access Error
•
Protection Fault
•
Illegal Word Operand Access
The Class B traps share the same trap priority and the same vector address.
The bit-addressable Trap Flag Register (TFR) allows a trap service routine to identify the
kind of trap which caused the exception. Each trap function is indicated by a separate
request flag. When a hardware trap occurs, the corresponding request flag in register
TFR is set to ‘1’.
The reset functions may be regarded as a type of trap. Reset functions have the highest
system priority (trap priority III).
Class A traps have the second highest priority (trap priority II), on the 3
rd
rank are
Class B traps, so a Class A trap can interrupt a Class B trap. If more than one Class A
trap occur at a time, they are prioritized internally, with the SR0 trap at the highest and
the software break trap at the lowest priority.
In the case where e.g. an Undefined Opcode trap (Class B) occurs simultaneously with
an SR0 trap (Class A), both the SR0 and the UNDOPC flag is set, the IP of the instruction
with the undefined opcode is pushed onto the system stack, but the SR0 trap is
executed. After return from the SR0 service routine, the IP is popped from the stack and
immediately pushed again because of the pending UNDOPC trap.
Note: The trap service routine must clear the respective trap flag; otherwise, a new trap
will be requested after exiting the service routine. Setting a trap request flag by
software causes the same effects as if it had been set by hardware.