R8C/38T-A Group
11. Interrupts
Under development Preliminary document
Specifications in this document are tentative and subject to change.
R01UH0241EJ0010 Rev.0.10
Page 158 of 730
Aug 05, 2011
11.9.5
Rewriting Interrupt Control Register
(a) The contents of the interrupt control register can be rewritten only while no interrupt requests
corresponding to that register are generated. If an interrupt request may be generated, disable the interrupt
before rewriting the contents of the interrupt control register.
(b) When rewriting the contents of the interrupt control register after disabling the interrupt, be careful to
choose appropriate instructions
Changing any bit other than the IR bit
If an interrupt request corresponding to the register is generated while executing the instruction, the IR bit
may not be set to 1 (interrupt requested), and the interrupt may be ignored. If this causes a problem, use
one of the following instructions to rewrite the contents of the register:
Applicable instructions....... AND, OR, BCLR, and BSET
Changing the IR bit
Depending on the instruction used, the IR bit may not be set to 0 (no interrupt requested). Use the MOV
instruction to set the IR bit to 0.
(c) When using the I flag to disable an interrupt, set the I flag as shown in the sample programs below. (Refer
to (b) regarding rewriting the contents of interrupt control registers using the sample programs.)
Examples 1 to 3 show how to prevent the I flag from being set to 1 (interrupt enabled) before the contents of the
interrupt control register are rewritten due to effects of the internal bus and the instruction queue buffer.
Example 1: Use the NOP instructions to pause the program until the interrupt control register is
rewritten
INT_SWITCH1:
FCLR
I
; Interrupt disabled
AND.B
#00H, 0056H
; Set the TRJIC_0 register to 00h
NOP
;
NOP
FSET
I
; Interrupt enabled
Example 2: Use a dummy read to delay the FSET instruction
INT_SWITCH2:
FCLR
I
; Interrupt disabled
AND.B
#00H, 0056H
; Set the TRJIC_0 register to 00h
MOV.W
MEM, R0
; Dummy read
FSET
I
; Interrupt enabled
Example 3: Use the POPC instruction to change the I flag
INT_SWITCH3:
PUSHC
FLG
FCLR
I
; Interrupt disabled
AND.B
#00H, 0056H
; Set the TRJIC_0 register to 00h
POPC
FLG
; Interrupt enabled