![Texas Instruments TMS320C2x User Manual Download Page 149](http://html1.mh-extra.com/html/texas-instruments/tms320c2x/tms320c2x_user-manual_1097073149.webp)
Interrupt Handling
6-26
6.5.2 Using C Interrupt Routines
You can handle interrupts
directly
with C functions by using one of two conven-
tions:
-
Any function with the name c_int
d
, where
d
is a digit 0
−
9, is presumed to
be an interrupt routine. The name c_int0 is reserved for the system reset
interrupt; do not use this name for any other function. For example:
void c_int1()
{
...
}
-
Or, you can use the interrupt keyword. For example:
interrupt void isr()
{
...
}
Using one of these conventions defines an interrupt routine. When the
compiler encounters one of these routines, it generates code that allows the
function to be activated from an interrupt trap. This method provides more
functionality than the standard C signal mechanism. This does not prevent
implementation of the signal function, but it does allow these functions to be
written entirely in C.
When handling interrupts with C functions, remember the following:
-
An interrupt routine must be of type void, and it should be declared with
no arguments.
-
The compiler does
not
save all the device registers. The compiler saves
only those registers listed in Table 6
-
You must handle any special masking of interrupts via the IMR register.
You can use inline assembly language to enable or disable the interrupts
and modify the IMR register without corrupting the C environment.
-
An interrupt routine can be called by normal C code, but it is inefficient to
do so because all the registers are preserved by a calling C function.
-
An interrupt routine can handle a single interrupt or multiple interrupts. The
compiler does not generate code that is specific to a certain interrupt,
except for c_int0, which is the system reset interrupt.
-
None of the interrupt routines nor any of the functions they call can be
compiled with the
−
oe shell option (optimizer option
−
j). The
−
oe option
assumes that none of the functions in the module are interrupts, can be
called by interrupts, or can be otherwise executed in an asynchronous
manner, so compiling programs containing interrupt routines with this
option negates their use.
Summary of Contents for TMS320C2x
Page 8: ...viii...
Page 69: ...2 47 C Compiler Description...
Page 159: ...6 36...
Page 226: ...8 6...