Sleep Mode Setup in MPLAB® XC Compilers

Last modified by Microchip on 2024/01/17 22:15


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__)

#elif defined(__XC16__)
       /* or */

       /* or */

#elif defined(__XC32__)
       /* Wait instruction */