Sleep Mode Setup in XC Compilers
The MPLAB® XC compilers offer macros to invoke Sleep mode. Below is an example for each C compiler showing the sleep macro function for that compiler. Please 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
