131
µ
PD17062
11.9.4 Saving the Contents of System and Control Registers
The contents of system and control registers must be saved before using the multiple interrupt function.
The contents of these registers change during interrupt processing.
An area must be obtained for these contents for each interrupt source.
An interrupt being accepted and interrupts with lower priorities must be inhibited, and interrupts with
higher priorities must be permitted.
Because an interrupt with a high priority is an emergency interrupt, it should have first priority. Therefore,
the contents of system and control registers should be saved after permitting an interrupt with a high priority.
The following example describes processing of the interrupt processing routine to enable an interrupt with
a high priority and to save the contents of system and control registers:
Example Example of permitting an interrupt and saving register contents at multiple interrupts
Use the INTNC pin, VSYNC pin, and timer interrupts with the following software priorities:
VSYNC pin > timer > INTNC pin
A timer interrupt is assumed to be accepted in the first level.
The figure below shows an example program and flowchart for this processing.
Flowchart Program example
EI
RETI
EI
EI
DI
MOV
POKE
BANK1
POKE
PEEK
POKE
MOV
POKE
PEEK
POKE
PEEK
POKE
PEEK
POKE
PEEK
WR,
INTPM,
#0111B
WR
WR
INTPM
WR
#0100B
WR
WR,
M3,
WR,
INTPM,
M2
WR
M1
WR,
INTPM,
WR,
M3
WR
RPL
WR
M1,
WR,
M2,
WR,
INTPM,
V
SYNC
, INT
NC
, and timer
interrupt permission
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
(built-in macro)
;
Bank specification
Window register saving
Interrupt permission flag
saving
Permission of interrupt
with high priority
System register saving
Interrupt processing
System register restoration
Interrupt permission
flag restoration
Window register restoration
Permit timer, INT
NC
pin, and V
SYNC
pin interrupts
using the interrupt permission register.
The contents of the bank register, index enable flag,
and program counter are automatically saved.
Restore the contents of the interrupt
permission register.
Restores the contents of the window register.
Restore the contents of system
and control registers other than window
and interrupt permission registers.
Save the contents of system and
control registers other than window
and interrupt permission registers.
Saves the window register.
Save the interrupt permission
register in data memory M2.
Permit a V
SYNC
pin interrupt using
the interrupt permission register.
Specifies that the data is saved in BANK1.
Timer interrupt
Main routine