beautypg.com

8 effective usage of interrupts, 9 application of interrupt – NEC PD754144 User Manual

Page 204

background image

CHAPTER 7 INTERRUPT AND TEST FUNCTIONS

204

User’s Manual U10676EJ3V0UM

7.8 Effective Usage of Interrupts

Use the interrupt function effectively as follows.

(1) Use different register banks for the normal routine and interrupt routine.

The normal routine uses register banks 2 and 3 with RBE = 1 and RBS = 2. For the interrupt service routine

for one nested interrupt, use register bank 0 with RBE = 0, so that you do not have to save or restore the

registers. When two or more interrupts are nested, set RBE to 1, save the register bank by using the PUSH

BR instruction, and set RBS to 1 to select register bank 1.

(2) Use the software interrupt for debugging.

Even if an interrupt request flag is set by an instruction, the same operation as when an interrupt occurs is

performed. For debugging of an irregular interrupt or debugging when two or more interrupts occur at the same

time, the efficiency can be increased by using an instruction to set the interrupt flag.

7.9 Application of Interrupt

To use the interrupt function, first set as follows using the main program.

(a) Set the interrupt enable flag of the interrupt used (by using the EI IE

××× instruction).

(b) To use INT0, select the active edge (set IM0).

(c) To use nesting (of an interrupt with a higher priority), set IPS (IME can be set at the same time).

(d) Set the interrupt master enable flag (by using the EI instruction).

In the interrupt service program, MBE and RBE are set by the vector table. However, when the interrupt specified

as having a higher priority is serviced, the register bank must be saved and set.

To return from the interrupt service routine, use the RETI instruction.

This manual is related to the following products: