Sleep/developers

From Wiring

Jump to: navigation, search
This page is intended as a reference for core developers only, and the content is only changed after a consensus has been reached through discussion of any such changes. Please use the Discussion page to talk about any changes or issues you have with the current implementation.
sleep()
Classification Sleep power management utility functions
Suggested location WSleep.h
C++ required No
Timing constraints None
Version introduced 1.0 (0100)
Framework dependencies None
Prototype(s)
static inline void sleep()
Required? Yes
Issues None


Contents

Description

The sleep() command can allow an application to reduce its power comsumption considerably.

Black Box Input

No input.

Black Box Output

Nothing is returned.

Overloading

None. Single function only.

Notes

Sleep modes enable the application to shut down unused modules in the microcontroller, thereby saving power. The default mode is SLEEP_IDLE. Different AVR devices provides various sleep modes allowing the user to tailor the power consumption to the application's requirements. There are six sleep modes set by the sleepMode() command.

SLEEP_IDLE: makes the MCU enter Idle mode, stopping the CPU but allowing the SPI, Serial, Analog Comparator, ADC, Wire, Timer/Counters and the interrupt system to continue operating. This mode enables the microcontroller to wake up from external triggered interrupts as well as internal ones like the Timer Overflow and Serial Transmit Complete interrupts.

SLEEP_ADC: makes the microcontroller enter ADC Noise Reduction mode, stopping the CPU but allowing the ADC, the external interrupts, Wire Serial Interface address match and Timer/Counter2. This improves the noise environment for the ADC, enabling higher resolution measurements. If the ADC is enabled, a conversion starts automatically when this mode is entered. Only an External Reset, a Wire serial interface interrupt, a Timer/Counter2 interrupt, an SPM/EEPROM ready interrupt, an external level interrupt on INT7:4 or a pin change interrupt can wakeup the microcontroller from ADC Noise Reduction mode.

SLEEP_POWER_DOWN: In this mode, the external Oscillator is stopped, while the external interrupts, and the Wire Serial Interface continue operating. Only an External Reset, Wire Serial Interface address match, an external level interrupt on INT7:4, an external interrupt on INT3:0, or a pin change interrupt can wake up the microcontroller. This sleep mode basically halts all generated clocks, allowing operation of asynchronous modules only.

SLEEP_POWER_SAVE: This mode is identical to SLEEP_POWER_DOWN, with one exception: If Timer/Counter2 is enabled, it will keep running during sleep. The device can wake up from either Timer Overflow or Output Compare event from Timer/Counter2 if the corresponding Timer/Counter2 interrupt enable bits are set, and the Global Interrupts are enable. If Timer/Counter2 is not running, SLEEP_POWER_DOWN mode is recommended instead of

SLEEP_POWER_SAVE mode. The Timer/Counter2 can be clocked both synchronously and asynchronously in SLEEP_POWER_SAVE mode. If the Timer/Counter2 is not using the asynchronous clock, the Timer/Counter Oscillator is stopped during sleep. If the Timer/Counter2 is not using the synchronous clock, the clock source is stopped during sleep. Note that even if the synchronous clock is running in SLEEP_POWER_SAVE, this clock is only available for the Timer/Counter2.

SLEEP_STANDBY: This mode is identical to SLEEP_POWER_SAVE mode with the exception that the Oscillator is kept running.

SLEEP_EXTENDED_STANDBY: This mode is identical to SLEEP_POWER_SAVE mode with the exception that the Oscillator is kept running. From SLEEP_EXTENDED_STANDBY mode, the device wakes up in six clock cycles.

Proposed Changes

Personal tools