8.7.6 sleep_mode Macro

Enable sleep mode and put the device to sleep.

Include

<avr/sleep.h>

Prototype

void sleep_mode(void);

Remarks

This macro clears the sleep enable bit, puts the device to sleep, and disables the sleep enable bit afterwards. As this macro might cause race conditions in some situations, you might prefer to use the macros which perform these individual steps, ensuring that interrupts are enabled immediately prior to the device being put to sleep.

Example

#include <xc.h>
#include <avr/sleep.h>
int main(void)
{
  initSystem();
  sleep_mode();
}