mspgcc: A port of the GNU tools to the Texas Instruments MSP430 microcontrollers | ||
---|---|---|
<<< Previous | MSP430 specific extensions to the GNU toolchain | Next >>> |
mspgcc allows interrupt service routines to be written efficiently in C. To access the interrupt features of mspgcc the header file
#include <signal.h>
To make a routine an interrupt service routine, define it as follows:
interrupt (INTERRUPT_VECTOR) IntServiceRoutine(void) { /* Any normal C code */ } |
interrupt (INTERRUPT_VECTOR) [wakeup, enablenested] IntServiceRoutine(void) { /* Any normal C code */ } |
Although interrupt service routines normally accept no arguments, it is possible to define a function with the "interrupt" attribute and an argument list. The compiler will correctly allow for the extra register (r2) pushed on the stack, when accessing parameters on the stack. Parameters passed in registers are, obviously, unaffected by this. The ability to define functions in this way is provided for completeness. Their usefulness may be limited.
It should be noted that there is a performance hit associated with any function calls within an interrupt service routine (unless the function is of the "inline" type, which does not result in an actual function call instruction). Any call requires the compiler save register r12, r13, r14 and r15 on the stack during the function call. For example, something as simple as:
uint32_t localtime; void incloctime() { localtime++; } interrupt(BASICTIMER_VECTOR) isr() { incloctime(); } |
For every device, the macros "NOVECTOR" and "RESET_VECTOR" are defined. If an interrupt service routine is declared as
interrupt (NOVECTOR) [wakeup, enablenested] IntServiceRoutine(void) { /* Any normal C code */ } |
<<< Previous | Home | Next >>> |
Function attributes | Up | Customising the interrupt vector table |