The ATmega architecture provides power saving modes of operation to reduce to total power consumption of the microcontroller. The number and type of power saving modes depends on the exact chip in the ATmega family. Power saving modes are very useful when designing an embedded solution that will be powered of a limited power source, such as a coin-cell, solar power, or energy harvesting method.
AVR-LibC provides a good library for utilising the sleep modes on an ATmega microcontroller. To use them, make sure to include sleep.h from AVR-LibC into your project. If using AVR Studio 5, this can be done with the following inclusion at the top of your code.
The following code examples make use of the functions provided by this library.
|Mode||clkCPU||clkFLASH||clkI/O||Can Wake Up From||Notes|
||Stops the cpu and flash access, but allows all other components to run.|
|ADC Noise Reduction Mode||0||0||0||
||Improves the noise performance of the ADC. Use this if you want to do hard-core ADC measurements and get the maximum possible resolution.|
Putting The Micro To Sleep
There are three functions from the AVR-LibC sleep library that need to be called to make the microcontroller enter a sleep mode. The first is set_sleep_mode(mode).
Things To Watch Out For
- USART/other comm transmissions have finished before you enter a sleep mode which stops the USART clock. If not, you will be sending corrupted data.
Posted: September 15th, 2011 at 9:52 am
Last Updated on: May 13th, 2013 at 9:56 am