The CC-RH can describe an "Interrupt handler" or "Exception handler" that is called if an interrupt or exception occurs. This section explains how to describe these handlers.
If an interrupt or exception occurs in the RH850 family, the program jumps to a handler address corresponding to the interrupt or exception.
The arrangement of the handler addresses and the available interrupts vary depending on the device of the RH850. See the Relevant Device's User's Manual of each device for details.
How to describe interrupt servicing is explained specifically in "(3) Describing interrupt/exception handler".
If an interrupt/exception occurs while a function is being executed, interrupt/exception processing must be immediately executed. When the interrupt/exception processing is completed, execution must return to the function that was interrupted.
Therefore, the register information at that time must be saved when an interrupt/exception occurs, and the register information must be restored when interrupt/exception processing is complete.
The format in which an interrupt/exception handler is described does not differ from ordinary C functions, but the functions described in C must be recognized as an interrupt/exception handler by the CC-RH. With the CC-RH, an interrupt/exception handler is specified using the #pragma interrupt directive.
#pragma interrupt ( function-specification [, function-specification]... )Note function-specification: function-name [(interrupt specification [, interrupt specification]...)] |
Describe functions that are described in the C language. In the case of a function, "void func1() {}", specify "func1".
Always give interrupt functions a return type of void.
The function exit code of an interrupt function is different from that of an ordinary function. You must therefore not call them in the same way as ordinary functions.
You can define an interrupt function with either no parameters or one parameter.
The following interrupt specification can be specified.
If you write an interrupt specification, you must include a term to the right of the equals sign ("=").
For example, writing only "enable=" will cause a compilation error. The default interrupt specification signifies the behavior when individual interrupt specifications are not written.
The compiler inserts the following instructions at the entrance and exit of an EI level exception interrupt function. EIINT and FPI are some of the main corresponding items.
However, this is not inserted into all interrupt functions. Necessary processing is output in accordance with user-defined #pragma statements, compiler options, etc.
(1) Allocates stack area for saving context
(2) Saves Caller-Save register used in interrupt function
(4) If the function has a formal parameter, set EIIC to R6
(5) Enables multiplex interrupts
(8) Sets imprecise interrupt standby
(11) Disables multiplex interrupts
(13) Restores Caller-Save register used in interrupt function
(14) Frees stack area for saving context
Below is a specific example of the output code. Numbers (1) to (15) in the code correspond to the numbered actions above.
Note that the instructions in the output code will not necessarily be identical to this example. The instructions, general-purpose registers, and other details may differ from this example.
#pragma interrupt func1(enable=true, callt=true, fpu=true) void func1(unsigned long eiic) { User-coded processing; } |
Sample2: output of EI level exception |
#pragma interrupt func1(enable=true, callt=true, fpu=true) void func1(unsigned long eiic) { User-coded processing; } |
The compiler inserts the following instructions at the entrance and exit of an FE level exception interrupt function. FEINT and PIE are some of the main corresponding items.
However, this is not inserted into all interrupt functions. Necessary processing is output in accordance with user-defined #pragma statements, compiler options, etc.
(1) Allocates stack area for saving context
(2) Saves all Caller-Save register used in interrupt function
(3) If the function has a formal parameter, sets FEIC to R6
(8) Restores all Caller-Save register used in interrupt function
(9) Frees stack area for saving context
Below is a specific example of the output code. Numbers (1) to (10) in the code correspond to the numbered actions above.
Note that the instructions in the output code will not necessarily be identical to this example. The instructions, general-purpose registers, and other details may differ from this example.
#pragma interrupt func1(priority=feint, callt=true, fpu=true) void func1(unsigned long feic) { User-coded processing; } |
The compiler inserts the following instructions at the entrance and exit of an FE level exception (cannot recover/restore) interrupt function. FENMI and SYSERR are some of the main corresponding items.
(1) If the function has a formal parameter, sets FEIC to R6
Nothing is output if the function does not have any parameters.
No saving or restoration of context is output. |
Below is a specific example of the output code. Numbers (1) in the code correspond to the numbered actions above.
#pragma inline_asm, #pragma inline, #pragma noinline, #pragma interrupt,