R01UH0136EJ0210 Rev.2.10
Page 765 of 800
Jul 31, 2012
M16C/64A Group
32. Usage Notes
32.9.5
Rewriting the Interrupt Control Register
To modify the interrupt control register, follow either of the procedures below:
•
Modify in places where no interrupt requests corresponding to the interrupt control register may
occur.
•
If an interrupt request can be generated, disable that interrupt and then rewrite the interrupt control
register.
When using the I flag to disable an interrupt, set the I flag as shown in the sample program code below.
(Refer to 32.9.6 “Instruction to Rewrite the Interrupt Control Register” for rewriting the interrupt control
registers using the sample program code.)
Examples 1 through 3 show how to prevent the I flag from becoming 1 (interrupt enabled) before the
contents of the interrupt control register is rewritten, owing to the effects of the internal bus and the
instruction queue buffer.
Example 1: Using the NOP instruction to pause the program 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.
Example 2: Using a dummy read to delay the FSET instruction
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 change 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.
32.9.6
Instruction to Rewrite the Interrupt Control Register
•
Do not use the BTSTC and BTSTS instructions to rewrite the interrupt control registers.
•
Use the AND, OR, BCLR, BSET, or MOV instruction to rewrite interrupt control registers.
When an interrupt request is generated for the register being rewritten while executing an AND,
OR, BCLR, or BSET instruction, the IR bit becomes 1 (interrupt requested) and remains 1.
Содержание M16C/60 Series
Страница 853: ...M16C 64A Group R01UH0136EJ0210...