ARM Technical Support Knowledge Articles

Low Power RTX Applications on Cortex-M Devices

Applies to: RealView Real-Time Library


Information in this knowledgebase article applies to:


An RTX application configured for low power operation is losing events when:


  1. The Event Register is not being set by interrupts on some Cortex-M3 silicon revision prior to r2p1.
  2. The WFE instruction is not available on some Cortex-M implementations so WFI is used to enter deep sleep.

When using Cortex-M low-power mode, RTX tick-less operation is controlled from the idle task.
Typical example:

__task void os_idle_demon (void) {
  uint32_t sleep;

  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;    /* Configure Cortex-M for deep sleep  */
  /* Configure your system for deep sleep */

  for (;;) {
    sleep = os_suspend ();              /* OS Suspend                         */

    if (sleep) {
      /* Setup and enable wakeup timer here */

      /* Put Cortex-M into deep sleep mode */
      __WFE ();                         /* Wait for event                     */

      /* Adjust actual sleep time (in case of any event) */
      sleep = ...
    os_resume (sleep);                  /* OS Resume                          */

Problem arises when an interrupt which interracts with RTX is triggered after os_suspend returned sleep time and before __WFE is called. If WFE instruction is available and is implemented correctly, an exception entry/exit event is latched in the event register, so when WFE is executed, this event is detected, CPU does not enter sleep mode, entire loop is repeated and sleep time recalculated.

In case a.) event register is not set by interrupt and when WFE is executed, core enters sleep mode and waits for next interrupt. Sleep time may be to long since it was not adjusted and as a consequence RTX events may be lost.

In case b.) when WFE is not implemented WFI can be used instead.




Request the files attached to this knowledgebase article.

Article last edited on: 2012-09-11 06:29:56

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential