
5. Program examples
The program examples are described as follow:
(1) For assembler
Example 1:
INT_SWITCH1:
FCLR I ; Disable interrupts.
AND.B #00h, 0055h ; Clear TA0IC int. priority level and int. request bit.
NOP ;
Four NOP instructions are required when using HOLD function.
NOP
FSET I ; Enable interrupts.
Example 2:
INT_SWITCH2:
FCLR I ; Disable interrupts.
AND.B #00h, 0055h ; Clear TA0IC int. priority level and int. request bit.
MOV.W MEM, R0 ; Dummy read.
FSET I ; Enable interrupts.
Example 3:
INT_SWITCH3:
PUSHC FLG ; Push Flag register onto stack
FCLR I ; Disable interrupts.
AND.B #00h, 0055h ; Clear TA0IC int. priority level and int. request bit.
POPC FLG ; Enable interrupts.
The reason why two NOP instructions (four when using the HOLD function) or dummy read are inserted
before FSET I in Examples 1 and 2 is to prevent the interrupt enable flag I from being set before the
interrupt control register is rewritten due to effects of the instruction queue.
(2) For C language
#pragma ASM
INT_SWITCH:
FCLR I
#pragma ENDASM
TA0IC & =00 ;
/* Clear TA0IC int. priority level and int. request bit. */
#pragma ASM
NOP
; Four NOP instructions are required when using HOLD function.
NOP
FSET I
#pragma ENDASM
No.M16C-14-9805
( 3 / 3 )
Kommentare zu diesen Handbüchern