15.7.2 PSV Usage with Interrupt Service Routines - dsPIC33C/E/F and dsPIC30 Devices Only [DD]

Managed PSV pointers and CodeGuard Security PSV constant sections in the compiler mean that ISRs cannot make any assumptions about the setting of PSVPAG. Two function attributes are available to help with this: auto_psv and no_auto_psv.

If an ISR references const variables or string literals using the constants-in-code memory model, the auto_psv attribute should be added to the function definition. This attribute will cause the compiler to preserve the previous contents of PSVPAG and set it to section .const. Upon exit, the previous value of PSVPAG will be restored. For example:

void __attribute__((interrupt, auto_psv)) _T1Interrupt()
{
   /* This function can reference const variables and
   string literals with the constants-in-code memory model. */
}

The no_auto_psv attribute is used to indicate that an ISR does not reference the auto_psv constants section. If neither attribute is specified, the compiler assumes auto_psv and inserts the necessary instructions to ensure correct operation at run time. A warning diagnostic message is also issued that alerts the user to the migration issue, and to the possibility of reducing interrupt latency by specifying the no_auto_psv attribute.