15.2.1 Example: Create Multiple Vector Tables in Flash
This example creates two vector tables at compile time. Each table has a unique timer interrupt and shares a PWM interrupt.
void __attribute__((interrupt)) _T1Interrupt(void)
{ /* this handler appears in IVT '0' */ }
void __attribute__((interrupt)) _T1Interrupt_42(void)
{ /* this handler appears in IVT '42' */ }
void __attribute__((interrupt)) _PWM1Interrupt(void)
{ /* this handler appears in IVT '0' and '42' */ }
extern void (**_ivt_0)(void) __attribute__((far));
extern void (**_ivt_42)(void) __attribute__((far));
int main()
{
/* execution begins with IVT '0' active */
/* switch to IVT '42' */
__builtin_setIVTBASE(&_ivt_42);
/* later, switch back to IVT '0' */
__builtin_setIVTBASE(&_ivt_0);
}