The basics of low-power programming on the Cortex-M0

Joseph Yiu, ARM Ltd.

October 25, 2011

Joseph Yiu, ARM Ltd.

Using the Send-Event-on-Feed Feature
The Send-Even t-on-Pend feature allows any interrupts (including disabled ones) to wake up the processor if the processor entered sleep by executing the WFE instruction.

When the SEVONPEND bit in the System Control Register is set, an interrupt switching from inactive state to pending state generates an event, which wakes up the processor from WFE sleep.

If the pending status of an interrupt was already set before the processor entered the sleep state, a new request from this interrupt during WFE sleep will not wake up the processor.

For users of CMSIS-compliant device driver libraries, the Send-Event-on-Pend feature can be enabled by setting bit 4 in the System Control Register. For example, you can use

SCB->SCR |- 1<<4; /* Enable Send-Event-on-Send feature */

If you are not using a CMSIS-compliant device driver library, you can use the following C code to carry out the same operation:

#define SCB SCR (* ((volatile unsigned long*) (OxEOOOEDl0)))
/* Set SEVONPEND bit in System Control Register * /
SCB_SCR | = 1<<4;

Users of assembly language can enable this feature by using the following assembly code:

LDR     r0, =OxEOOOED10; System Control Register address
LDR     rl, [r0]
MOVS    r2, #0x10; Set SEVONPEND bit
ORR     r1, r2
STR     rl, [r0]

Using the Sleep-on-Exit Feature
The Sleep-on-Exit feature is ideal for interrupt-driven applications. When it is enabled, the processor can enter sleep as soon as it completes an exception handler and returns to Thread mode.

It does not cause the processor to enter sleep if the exception handler is returning to another exception handler (nested interrupt). By using Sleep-on-Exit, the microcontroller can stay in sleep mode as much as possible (Figure 17.3 below).

Figure 17.3: Sleep-on-Exit feature.
When the Cortex-MO enters sleep using the Sleep-on-Exit feature, it is just like executing WFI immediately after the exception exit.

However, the unstacking process is not carried out because the registers will have to be pushed onto the stack at the next exception entry.

The Sleep-on-Exit feature reduces the power consumption of the system (1) by avoiding unnecessary program execution in thread in interrupt-driven applications and (2) by reducing unnecessary stack push and pop operations.

When the processor is awakened by a halt debug request, then the unstacking process will be carried out automatically. When the Sleep-on-Exit feature is used, the WIFE or WFI instruction is normally placed in an idle loop:

SCB-> SCR= SCB|0x2;// Enable S1eep-on-exit feature
while (1){
   _WFI();// Execute WFI and enter sleep
   }
;

The loop is required because if the processor is awakened by a halt debug request, the instruction after the WFI (branch back to WFI loop) would be executed when the processor is unhalted after debugging.

If you are not using a CMSIS-compliant device driver, you can use the following C code to enable the Sleep-on-Exit feature:

#define SCB_SCR (*((volatile unsigned long *)(0xE000ED10)))
/* Set SLEEPONEXIT bit in System Control Register */
SCB_SCR = SCB_SCR | 0x2;

Users of assembly language can enable this feature using the following assembly code:

LDR     r0, =0xE000ED10; System Control Register address
LDR     r1, [r0]
MOVS    r2, #0x2
ORR     r1, r2; Set SLEEPONEXIT bit
STR     r1, [r0]

In interrupt-driven applications, do not enable the Sleep-on-Exit feature too early during the initialization. Otherwise if the processor receives an interrupt request during the initialization process, it will enter sleep automatically after the interrupt handler is executed, before the rest of the initialization process completes.

< Previous
Page 2 of 5
Next >

Loading comments...

Most Commented

  • Currently no items

Parts Search Datasheets.com

KNOWLEDGE CENTER