16.4.2 context Attribute

The context attribute may be applied to an interrupt service routine to inform the compiler that this ISR executes at a particular Interrupt Priority Level (IPL), which has also been assigned to an alternate register set. Please see your device data sheet or Family Reference Manual (FRM) for details on how to properly configure the device to use alternate register sets. This feature is set up using configuration bits.

When using this attribute, it is important that the priority level of the interrupt matches the priority level of the context that has been assigned. Changing the priority of the interrupt service routine may cause runtime corruption.

Example of use:

 // Priority Level 7 routines will use context 1
 #pragma config CTXT1 = 7
 // T1 Interrupt uses its own context
 void __attribute__((interrupt, context)) _T1Interrupt(void);
 main() {
    // Timer 1 is configured to use priority level 7
    IPC0bits.T1IP = 7;