15.4.1 Interrupt Vector Usage
To field an interrupt, a function’s address must be placed at the appropriate address in one of the vector tables, with the function preserving any system resources that it uses. It must return to the foreground task using a RETFIE processor instruction. Interrupt functions may be written in C or Assembly. When a C function is designated as an interrupt handler, the compiler arranges to preserve all the system resources that the compiler uses, and to return from the function using the appropriate instruction. The compiler can optionally arrange for the interrupt vector table to be populated with the interrupt function’s address.
To arrange for the compiler to fill in the interrupt vector to point to the interrupt function, name the function as denoted in the vector tables (see 15.4.2 Available Interrupt Vectors.)
As an example, the vector name is _StackErrorTrap. So for the stack
error vector:
void __attribute__((interrupt)) _StackErrorTrap(void);
For all interrupt vectors without specific handlers, a default interrupt
handler will be installed. The default interrupt handler is supplied by the linker and
simply resets the device. An application may also provide a default interrupt handler by
declaring an interrupt function with the name _DefaultInterrupt.
