Atmel XMEGA-A1 Xplained Evaluation Board ATAVRXPLAIN ATAVRXPLAIN Hoja De Datos

Los códigos de productos
ATAVRXPLAIN
Descargar
Página de 13
 
AVR1010
 
 
9
8267B-AVR-12/10 
consumption for the different Atmel
®
 AVR
®
 XMEGA
®
 devices. The code steps through 
the following modes, staying for 8 seconds in each: 
• ACTIVE 
• IDLE 
• POWER-SAVE 
• POWER-DOWN 
Note that the device will stay in POWER-DOWN, since an external interrupt is 
required to wake the device up from this sleep mode. 
3.2 Sleep Example 
All the 
sleep_example.c
 examples are meant as “code skeletons”. By default, the 
device is woken up at 5 second intervals, held in ACTIVE for half a second, then put 
to sleep in POWER-SAVE or POWER-DOWN mode. The user may build on this 
example for his/her application. 
4 Sleep manager 
4.1 Purpose 
For this application note, a sleep manager has been implemented. Centralized control 
of sleep is necessary in applications that consist of several firmware modules that 
require different sleep modes depending on their status or activity level. Otherwise, 
one would risk that the firmware modules disrupted each other’s operation. 
4.2 Operation  
The sleep manager resides in 
sleepmgr.c
sleepmgr.h
 and 
config_sleepmgr.h
and can be accessed via the following four functions: 
void SLEEPMGR_Init( void ); 
void SLEEPMGR_Lock( SLEEPMGR_mode_t mode ); 
void SLEEPMGR_Unlock( SLEEPMGR_mode_t mode ); 
void SLEEPMGR_Sleep( void ); 
 
Prior to use, the sleep manager must be initialized to ensure correct operation. 
It then keeps track of which sleep mode is allowable by the use of locks. This is 
simply a list of values, with a one-to-one correspondence with a list of sleep modes 
that are defined at compile-time. The firmware modules may individually lock and 
unlock the sleep modes (increase/decrease the locks’ values) to prevent the sleep 
manager from putting the device in “too deep” sleep, i.e., modes that would interfere 
with the modules’ operation. 
When the sleep manager is requested to put the device to sleep, it searches through 
the locks for the first non-zero value. The device is then put to sleep in the mode 
which this lock corresponds to. Consequently, the order of the locks must be such 
that the deeper sleep modes come later. If no locks have been set after initialization, 
the sleep manager will default to the deepest sleep mode. Interrupts are disabled to 
prevent the locks from changing during this search. Any pending interrupts will cause 
the device to instantly wake up again.