Sleep Mode Setup in XC Compilers
The MPLAB ® XC compilers offer macros to invoke sleep mode. Provided here is an example for each C compiler showing the sleep macro function for that compiler. Note that they are case sensitive!
/*******************************************************************************
* Enter Sleep mode
* This macro issues the SLEEP instruction to shut down the system oscillator
* and enter low power operating mode.
******************************************************************************/
#if defined(__XC8__)
SLEEP();
#elif defined(__XC16__)
Sleep();
/* or */
__builtin_pwrsav(0);
Idle();
/* or */
__builtin_pwrsav(1);
#elif defined(__XC32__)
/* Wait instruction */
_wait();
#endif

