English
Language : 

TC9324F Datasheet, PDF (37/101 Pages) Toshiba Semiconductor – Single-Chip DTS Microcontroller (DTS-20)
TC9324F
3. Return from Interrupt Handling Routine
To recover from an interrupt handling routine and return to the processing taking place before the
interrupt, a special instruction is used. This is the RNI instruction. When the RNI instruction is issued, the
following processing is automatically performed in the order shown.
1) The contents of the address stack specified by the stack pointer are restored to the program
counter.
2) The interrupt master enable flag is set to 1 (enabled).
3) The stack pointer contents are incremented by 1.
The RNI instruction completes the above processing in one instruction cycle.
4. Interrupt Handling Routine
If the interrupt occurs in an interrupt-enabled area of the program, the interrupt is accepted at the point
the interrupt request is issued regardless of the program being executed at that time. Accordingly, when
returning to the original program after the interrupt handling is completed, it is necessary to recover as if
no interrupt handling had taken place. Therefore, at the very least, any registers or data memory that
might be processed during the interrupt handling routine must be saved before and restored after the
interrupt handling routine.
(1) Saving
In save processing, the carry flag must be saved. If an interrupt is accepted during an arithmetic
operation, the contents of the carry flag (CY) and other data change, causing the program to make
errors of judgment after restoration. This is why it is necessary to use the IN1 instruction to save the
contents of the carry flag in the I/O map to data memory.
If necessary, also save the contents of the data memory and general registers used by the interrupt
handling routine. When using such instructions as MVGD, MVGS, and DAL in the interrupt routine,
also save the G-register, DAL address register, and other contents.
(2) Restoring
The restoration process is simply an inversion of the above saving process.
Because the interrupt master enable flag is reset to 0 when an interrupt is accepted, naturally
enough, before the interrupt was accepted the flag must have been set to 1. Therefore, use the RNI
instruction to return the master enable flag to its original state.
5. Multiple Interrupts
Multiple interrupt processing allows an interrupt to be handled at the same time another interrupt is
being handled. As in the diagram, during handling of an interrupt for interrupt source A or B, another
interrupt with source C or D can be handled. The interrupt depth at such a time is known as the interrupt
level.
Main
routine
Interrupt
level 1
Interrupt
level 2
Interrupt
level 3
Interrupt
level 4
MAIN
B
D
A
B
C
D
C
Example of Multiple Interrupts
37
2002-02-08