79
SAM4CP [DATASHEET]
43051E–ATPL–08/14
12.5.1.3 Sleep-on-exit
If the SLEEPONEXIT bit of the SCR is set to 1 when the processor completes the execution of an exception handler, it
returns to Thread mode and immediately enters sleep mode. Use this mechanism in applications that only require the
processor to run when an exception occurs.
12.5.2 Wakeup from Sleep Mode
The conditions for the processor to wake up depend on the mechanism that cause it to enter sleep mode.
12.5.2.1 Wakeup from WFI or Sleep-on-exit
Normally, the processor wakes up only when it detects an exception with sufficient priority to cause exception entry.
Some embedded systems might have to execute system restore tasks after the processor wakes up, and before it
executes an interrupt handler. To achieve this, set the PRIMASK bit to 1 and the FAULTMASK bit to 0. If an interrupt
arrives that is enabled and has a higher priority than the current exception priority, the processor wakes up but does not
execute the interrupt handler until the processor sets PRIMASK to zero. For more information about PRIMASK and
“Exception Mask Registers”
.
12.5.2.2 Wakeup from WFE
The processor wakes up if:
It detects an exception with sufficient priority to cause an exception entry.
It detects an external event signal. See
“External Event Input”
.
In a multiprocessor system, another processor in the system executes an SEV instruction.
In addition, if the SEVONPEND bit in the SCR is set to 1, any new pending interrupt triggers an event and wakes up the
processor, even if the interrupt is disabled or has insufficient priority to cause an exception entry. For more information
about the SCR, see
“System Control Register”
.
12.5.2.3 External Event Input
The processor provides an external event input signal. Peripherals can drive this signal, either to wake the processor
from WFE, or to set the internal WFE event register to 1 to indicate that the processor must not enter sleep mode on a
later WFE instruction. See
“Wait for Event”
for more information.
12.5.3 Power Management Programming Hints
ISO/IEC C cannot directly generate the WFI and WFE instructions. The CMSIS provides the following functions for these
instructions:
void __WFE(void) // Wait for Event
void __WFI(void) // Wait for Interrupt