19.3.1 Initialization
To enter a sleep mode, follow these steps:
- Configure and enable the interrupts that can wake the device from sleep mode.
- Enable global interrupts by writing the
Global Interrupt Enable (I) bit in the CPU Status Register (CPU.SREG) register to
‘
1
’. - Select the sleep mode to enter by writing to the Sleep Mode (SMODE) bit field in the Control A (SLPCTRL.CTRLA) register.
- Enable the Sleep Controller by writing to the Enable (SEN) bit in the Control A (SLPCTRL.CTRLA) register.
- Execute the
SLEEP
instruction to make the device enter the selected sleep mode.
Note: If executing a
SLEEP
instruction when the
Sleep Enable (SEN) bit in the Control A (CTRLA) register is ‘0
’ (CTRLA.SEN
= ‘0
’) or the Global Interrupt Enable (I) bit in the CPU Status Register
(CPU.SREG) register is ‘0
’ (CPU.SREG.I = ‘0
’), the SLEEP
instruction is disregarded - and the Sleep Error (SERR) flag in the Interrupt Flags
(SLPCTRL.INTFLAGS) register is set.Warning: When executing the
SLEEP
instruction, at least one interrupt that can wake the device
must be enabled. If no interrupts are enabled, the device cannot return from sleep mode,
and only a Reset will allow the device to resume ordinary
operation.