The CC-RH can disable the maskable interrupts in a C source.
This can be done in the following two ways.
The "di instruction" and "ei instruction" of the assembler instruction can be used to disable an interrupt locally in a function described in C language. However, the CC-RH has functions that can control the interrupts in a C language source.
void func1(void) { : __DI(); /*Describe processing to be performed with interrupt disabled.*/ __EI(); : } |
_func1: -- prologue code : di -- processing to be performed with interrupt disabled ei : -- epilogue code jmp [lp] |
The CC-RH has a "#pragma block_interrupt" directive that disables the interrupts of an entire function.
This directive is described as follows.
Describe functions that are described in the C language. In the case of a function, "void func1() {}", specify "func1".
The interrupt to the function specified by "function-name" above is disabled. As explained in "(1) Locally disabling interrupt in function", __ DI()" can be described at the beginning of a function and "__ EI()", at the end. In this case, however, an interrupt to the prologue code and epilogue code output by the CC-RH cannot be disabled or enabled, and therefore, interrupts in the entire function cannot be disabled.
Using the #pragma block_interrupt directive, interrupts are disabled immediately before execution of the prologue code, and enabled immediately after execution of the epilogue code. As a result, interrupts in the entire function can be disabled.
How to use the #pragma block_interrupt directive and the code that is output are shown below. |
#pragma block_interrupt func1 void func1(void) { : /*Describe processing to be performed with interrupt disabled.*/ : } |
_func1: di -- prologue code : -- processing to be performed with interrupt disabled : -- epilogue code ei jmp [lp] |
Note the following points when disabling interrupts in an entire function.
If the following functions are called in a function in which an interrupt is disabled, the interrupt is enabled when execution has returned from the call. |
Describe the #pragma block_interrupt directive before the function definition in the same file; otherwise an error occurs during compilation. |
A code that manipulates the ep flag (that indicates exception processing is in progress) in the program status word (PSW) is not output even if #pragma block_interrupt is specified. |
#pragma inline_asm, #pragma inline, #pragma noinline, #pragma interrupt,