Feb 07, 2019 If you are using Atmel Studio 7, you can also get the AVR-LibC documentation installed locally, for viewing in the AS7 help viewer. Go to Help Add and Remove Help Content, then find User Guides Software AVR LibC in the list and click 'Add', then 'Update' to install it.
- Http Www Nongnu Org Avr Libc User Manual Modules Html Download
- Avr Libc Download
- Avr Libc Manual
- Http://www.nongnu.org/avr-libc/user-manual/modules.html
Functions | |
void | sleep_enable (void) |
void | sleep_disable (void) |
void | sleep_cpu (void) |
void | sleep_mode (void) |
void | sleep_bod_disable (void) |
Detailed Description
- Using avr-libc Examples using avr-libc Generating timing delays: Note: compiler optimizations must be enabled and the delay time must be an expression that is a known constant at compile-time. #define FCPU must be defined as a constant. It defines the CPU clock frequency (in Hertz). The maximal possible delay is 262.14 ms / FCPU in MHz.
- Mar 19, 2012 1. Arduino programming language The Arduino basically uses the industry-standard C language, implemented by the GNU g compiler. For information on basic things like loops, strings, functions, data types, and so on try consulting one of the many online C references.
Use of the SLEEP
instruction can allow an application to reduce its power comsumption considerably. AVR devices can be put into different sleep modes. Refer to the datasheet for the details relating to the device you are using.
There are several macros provided in this header file to actually put the device into sleep mode. The simplest way is to optionally set the desired sleep mode using set_sleep_mode()
(it usually defaults to idle mode where the CPU is put on sleep but all peripheral clocks are still running), and then call sleep_mode()
. This macro automatically sets the sleep enable bit, goes to sleep, and clears the sleep enable bit.
Example:
Note that unless your purpose is to completely lock the CPU (until a hardware reset), interrupts need to be enabled before going to sleep.
As the sleep_mode()
macro might cause race conditions in some situations, the individual steps of manipulating the sleep enable (SE) bit, and actually issuing the SLEEP
instruction, are provided in the macros sleep_enable()
, sleep_disable()
, and sleep_cpu()
. This also allows for test-and-sleep scenarios that take care of not missing the interrupt that will awake the device from sleep.
Example:
This sequence ensures an atomic test of some_condition
with interrupts being disabled. If the condition is met, sleep mode will be prepared, and the SLEEP
instruction will be scheduled immediately after an SEI
instruction. As the intruction right after the SEI
is guaranteed to be executed before an interrupt could trigger, it is sure the device will really be put to sleep.
Some devices have the ability to disable the Brown Out Detector (BOD) before going to sleep. This will also reduce power while sleeping. If the specific AVR device has this ability then an additional macro is defined: sleep_bod_disable()
. This macro generates inlined assembly code that will correctly implement the timed sequence for disabling the BOD before sleeping. However, there is a limited number of cycles after the BOD has been disabled that the device can be put into sleep mode, otherwise the BOD will not truly be disabled. Recommended practice is to disable the BOD (sleep_bod_disable()
), set the interrupts (sei()
), and then put the device to sleep (sleep_cpu()
), like so:
Http Www Nongnu Org Avr Libc User Manual Modules Html Download
Function Documentation
Disable BOD before going to sleep. Not available on all devices.
Put the device into sleep mode. The SE bit must be set beforehand, and it is recommended to clear it afterwards.
Avr Libc Download
Clear the SE (sleep enable) bit.
Avr Libc Manual
Put the device in sleep mode. How the device is brought out of sleep mode depends on the specific mode selected with the set_sleep_mode() function. See the data sheet for your device for more details.
Set the SE (sleep enable) bit.
Http://www.nongnu.org/avr-libc/user-manual/modules.html
Put the device into sleep mode, taking care of setting the SE bit before, and clearing it afterwards.