![](http://datasheet.mmic.net.cn/30000/M30245MC-XXXGP_datasheet_2358670/M30245MC-XXXGP_58.png)
M30245 Group
Interrupts
Rev.2.00
Oct 16, 2006
page 56 of 264
REJ03B0005-0200
Example 1:Using the NOP instruction to keep the program waiting until the interrupt control register is
modified
INT_SWITCH1:
FCLR
I
; Disable interrupts.
AND.B
#00h, 0055h
; Set the TA0IC register to “00h”.
NOP
;
NOP
FSET
I
; Enable interrupts.
The number of NOP instruction is as follows.
PM20=1(1 wait) : 2, PM20=0(2 wait) : 3, when using HOLD function : 4.
Example 2:Using the dummy read to keep the FSET instruction waiting
INT_SWITCH2:
FCLR
I
; Disable interrupts.
AND.B
#00h, 0055h
; Set the TA0IC register to “00h”.
MOV.W
MEM, R0
; Dummy read.
FSET
I
; Enable interrupts.
Example 3:Using the POPC instruction to changing the I flag
INT_SWITCH3:
PUSHC
FLG
FCLR
I
; Disable interrupts.
AND.B
#00h, 0055h
; Set the TA0IC register to “00h”.
POPC
FLG
; Enable interrupts.
Interrupt Enable Flag (I flag)
The interrupt enable flag (I flag) controls the enabling and disabling of maskable interrupts. Setting this flag to "1"
enables all maskable interrupts; setting it to "0" disables all maskable interrupts. This flag is set to "0" after reset.
Interrupt Request Bit
The interrupt request bit is set to "1" by hardware when an interrupt is requested. After the interrupt is accepted and
jumps to the corresponding interrupt vector, the request bit is set to "0" by hardware. The interrupt request bit can also
be set to "0" by software. (Do not set this bit to "1").
Interrupt Sequence
The interrupt sequence, described below, is performed during the period from when an interrupt is accepted to when
the interrupt routine is executed.
If an interrupt occurs during execution of an instruction, the processor determines its priority when the execution of the
instruction is completed, and transfers control to the interrupt sequence from the next cycle. If an interrupt occurs during
execution of either the SMOVB, SMOVF, SSTR or RMPA instruction, the processor temporarily suspends the instruction
being executed, and transfers control to the interrupt sequence.
The processor carries out the following in sequence after an interrupt request:
(1) CPU gets the interrupt information (the interrupt number and interrupt request level) by reading address 0000016.
(2) Saves the contents of the flag register (FLG) as it was immediately before the start of interrupt sequence in
the temporary register (Note) within the CPU.
(3) Sets the interrupt enable flag (I flag), the debug flag (D flag), and the stack pointer select flag (U flag) to "0" (the U flag,
however does not change if the INT instruction, in software interrupt numbers 32 through 63, is executed).
(4) Saves the contents of the temporary register (Note) within the CPU in the stack area.
(5) Saves the contents of the program counter (PC) in the stack area.
(6) Sets the interrupt priority level of the accepted instruction in the IPL.
After the interrupt sequence is completed, the processor resumes executing instructions from the first address of the
interrupt routine.
Note: This register cannot be utilized by the user.