SLAU132V October 2004 – February 2020
The INTERRUPT pragma enables you to handle interrupts directly with C code. In C, the argument func is the name of a function. In C++, the pragma applies to the next function declared.
The syntax of the pragma in C is:
#pragma INTERRUPT (func) |
The syntax of the pragma in C++ is:
#pragma INTERRUPT
void func( void ) |
The GCC interrupt attribute syntax, which has the same effects as the INTERRUPT pragma, is as follows. Note that the interrupt attribute can precede either the function's definition or its declaration.
__attribute__((interrupt)) void func( void ) |
The return address of the interrupt function is placed on the stack.
The interrupt attribute syntax allows you to optionally specify a numeric argument that indicates the vector location as specified for the vector pragma. For example:
#define TIMER_A0 20
#define TIMER_A1 10
__attribute__((interrupt(TIMER_A0))) void foo1() {
int i;
for (i=1; i < 1000; i++)
global_ptr[i] = i;
}
NOTE
Hwi Objects and the INTERRUPT PragmaThe INTERRUPT pragma must not be used when SYS/BIOS Hwi objects are used in conjunction with C functions. The Hwi_enter/Hwi_exit macros and the Hwi dispatcher contain this functionality, and the use of the C modifier can cause negative results.
NOTE
Interrupt service routine (ISR) warningThe linker emits a warning for any device-specific interrupts with no associated interrupt service routine. However, a default vector handler is provided by the run-time support (RTS) library, so you should not see this error if you are linking with the provided RTS library.