Persistent Variable Setup
Persistent Variables are variables that should not be cleared by the runtime startup code such as during a reset. If you have a variable which you don't want to have initialized upon a Power On Reset (POR), Watch Dog Timer Reset (WDT), or Master Clear Reset (MCLR), define it as Persistent. This is often needed for bootloader entry / exit, when the application needs to differentiate between a WDT, MCLR, or other reset condition. An example of how to establish a Persistent Variable is provided below:
/*******************************************************************************
* Persistent RAM variables, which are not initialized at power up / reset.
*
******************************************************************************/
#if defined(__XC8__)
#ifdef __CCI__
__persistent unsigned char PORStatus;
#else
persistent unsigned char PORStatus;
#endif
#elif defined(__XC16__)
#ifdef __CCI__
__persistent int PORStatus;
#else
int PORStatus __attribute__((persistent));
#endif
#elif defined(__XC32__)
#ifdef __CCI__
__persistent int PORStatus;
#else
int PORStatus __attribute__((persistent));
#endif
#endif

