English
Language : 

M16C65 Datasheet, PDF (288/829 Pages) Renesas Technology Corp – RENESAS MCU M16C FAMILY / M16C/60
Under development
M16C/65 Group
Preliminary Specification
This is a preliminary specification and is subject to change.
14. Interrupts
14.13.5 Rewriting the Interrupt Control Register
(a) The interrupt control register for any interrupt should be modified in places where no requests for
that register may occur. If an interrupt request generation is a possibility, disable an interrupt and
then rewrite the contents of the interrupt control register.
(b) When rewriting the contents of the interrupt control register after disabling an interrupt, be careful
with the instruction used.
• Changing bits other than the IR bit
When interrupts corresponding to the register occur, the IR bit may not be set to 1 (interrupt
requested) and the interrupts may be ignored. If this causes a problem, use one of the
following instructions to change the registers.
Instructions: AND, OR, BCLR, or BSET.
• Changing the IR bit
Depending on the instruction used, the IR bit may not always be set to 0 (interrupt not
requested). Therefore, 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 program code
shown below. (Refer to (b) regarding rewriting the contents of the interrupt control registers using
the sample program code.)
Examples 1 through 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, 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.
The number of the NOP instructions is as follows.
PM20 = 1 (1 wait): 2, PM20 = 0 (2 waits): 3, when using the HOLD function: 4.
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.
REJ09B0484-0030 Rev.0.30 Sep 09, 2008
Page 253 of 791