Datasheet

Table Of Contents
Section 3 Exception Handling
Rev. 2.00 Jul. 04, 2007 Page 57 of 692
REJ09B0309-0200
3.5.3 Method for Clearing Interrupt Request Flags
Use the recommended method given below when clearing the flags in interrupt request registers
(IRR1, IRR2, and IWPR).
(1) Recommended method
Use a single instruction to clear flags. The bit manipulation instruction and byte-size data transfer
instruction can be used. Two examples of program code for clearing IRRI1 (bit 1 in IRR1) are
given below.
BCLR #1, @IRR1:8
MOV.B R1L, @IRR1:8 (set the value of R1L to B'11111101)
(2) Example of a malfunction
When flags are cleared with multiple instructions, other flags might be cleared during execution of
the instructions, even though they are currently set, and this will cause a malfunction.
Here is an example in which IRRI0 is cleared and disabled in the process of clearing IRRI1 (bit 1
in IRR1).
MOV.B @IRR1:8,R1L ......... IRRI0 = 0 at this time
AND.B #B'11111101,R1L ..... Here, IRRI0 = 1
MOV.B R1L,@IRR1:8 ......... IRRI0 is cleared to 0
In the above example, it is assumed that an IRQ0 interrupt is generated while the AND.B
instruction is executing.
The IRQ0 interrupt is disabled because, although the original objective is clearing IRRI1, IRRI0 is
also cleared.