3.10 __interrupt Keyword
The IAR __interrupt
keyword specifies the qualified function is an interrupt
handler. The interrupt vector is specified separately with a #pragma vector =
number
pragma that must precede the function.
Suggested Replacement
There is an MPLAB XC8 qualifier that performs a similar task to this keyword.
Use the MPLAB XC8 __interrupt
qualifier with the required vector
number as argument. The compiler provides predefined macros that represent the
vector numbers, for example SPI_STC_vect_num
.
Caveats
The Common C Interface must be enabled using -mext=cci
to use the
__interrupt
qualifier.
Examples
volatile int x;
#pragma vector=2
void __interrupt incIsr(void) {
x++;
}
to
MPLAB XC8 code similar
to:#include <xc.h>
volatile int x;
void __interrupt(2) incIsr(void) {
x++;
}
Further Information
See the Interrupts section in the MPLAB XC8 C Compiler User's Guide for AVR MCUs for more information on writing interrupt functions.