SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: Arm Sleep Mode Entry and Exit Differences: WFE vs WFI
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

Arm Sleep Mode Entry and Exit Differences: WFE vs WFI

Eileen David
Last updated: September 14, 2023 2:27 am
Eileen David 6 Min Read
Share
SHARE

The ARM Cortex architecture provides two instructions for entering sleep or low power mode – WFE (Wait For Event) and WFI (Wait For Interrupt). Understanding the differences between WFE and WFI is important for optimizing power consumption and wakeup latency in ARM-based systems.

Contents
What is WFE?What is WFI?Key Differences Between WFE and WFIWFE Detailed BehaviorWFI Detailed BehaviorUsing WFE and WFI in ARM SystemsConsiderations When Using WFE vs WFIConclusion

What is WFE?

WFE (Wait For Event) instructs the processor to enter a low power state until a wakeup event occurs. The processor may power down unused components while waiting for the event. WFE only responds to events generated by another processor core in a multi-core system. Events that trigger wakeup include:

  • Setting the CPU’s event flag register by another core
  • Executing a SEV instruction on another core
  • Asserting the physical CPU’s wakeup interrupt

WFE is used for synchronizing between cores in a multi-core ARM system. The instruction can minimize power consumption while waiting on operations running on other cores.

What is WFI?

WFI (Wait For Interrupt) also puts the processor into a low power state until resumed by an interrupt. However, WFI can be awakened by interrupts from any source, including:

  • Interrupts from internal system peripherals
  • External interrupts from GPIO pins
  • Virtual interrupts from a hypervisor
  • Physical CPU wakeup interrupts

WFI allows the processor to enter low power mode while waiting for any interrupt event in the system. This makes it more flexible than WFE for system-wide low power states.

Key Differences Between WFE and WFI

The main differences between WFE and WFI are:

  • Event Sources – WFE only wakes up on events from other cores. WFI wakes up on any interrupt.
  • Latency – WFE has lower wakeup latency as it only needs to check core internal events.
  • Coordination – WFE is used for synchronization between cores. WFI can independently enter low power mode.
  • Power Savings – WFI allows full system power down; WFE only affects the CPU/cluster.

WFE Detailed Behavior

The steps the processor takes when executing a WFE instruction are:

  1. Check if an event flag is already set for this processor – if yes, exit immediately
  2. Suspend execution and enter low power state
  3. Monitor event flag register and wakeup interrupt signals
  4. When event flag or interrupt detected, exit low power state
  5. Clear the event flag
  6. Resume execution after WFE instruction

The processor may power gate unused internal components while waiting for the wake event. However, it continues to monitor event flag registers and wakeup interrupts.

WFI Detailed Behavior

When executing a WFI instruction, the processor will:

  1. Check for any pending interrupts – if found, exit immediately
  2. Enter low power state, disabling interrupts
  3. Monitor incoming external, peripheral, virtual, and physical wakeup interrupts
  4. On receiving a valid interrupt, exit low power state
  5. Re-enable interrupt handling and fetch next instruction after WFI

WFI allows full system power down, except for interrupt monitoring logic. Interrupts are disabled during WFI to avoid immediately waking the processor again.

Using WFE and WFI in ARM Systems

The ARM Architecture Reference Manual recommends using WFE for core-to-core synchronization and WFI for general low power states waiting for any interrupt. Some usage examples include:

  • Use WFE when signaling between cores, for example with mutexes or semaphores.
  • Use WFE in a multicore interrupt handler to wake up other cores.
  • Use WFI when idling a core that is waiting for a peripheral or external interrupt.
  • Use WFI when entering low power mode in a single core system.

Software should use WFE and WFI whenever the processor does not need to actively run instructions. Preventing unwanted clocking and power usage can significantly reduce energy consumption.

Considerations When Using WFE vs WFI

There are some key considerations when deciding between using WFE or WFI:

  • Wakeup latency – WFE has lower latency as it only monitors core events.
  • Coordination overhead – WFE requires managing event flags between cores.
  • Peripheral readiness – Peripherals may require initialization code to run after WFI.
  • Interrupt sources – WFI can wake from more sources than WFE.
  • Power savings – WFI allows full system suspend; WFE only affects the CPU cluster.

So in summary, WFE has lower overhead and latency but works best for core synchronization. WFI provides greater flexibility and power savings when waiting for interrupts.

Conclusion

The ARM WFE and WFI instructions both allow entering low power states until a resume event occurs. However, WFE focuses on multi-core coordination by waiting for events from other cores. WFI provides more flexibility by waiting for any interrupt. Understanding their differences allows optimally utilizing these instructions to reduce power consumption in ARM devices.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article What is the difference between WFI and WFE arm cortex?
Next Article Arm Sleep Mode Entry and Exit Differences: WFE vs WFI
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

How much power does ARM CPU use?

ARM CPUs are designed to be power efficient while still…

6 Min Read

ARM Cortex-M4 Processor Specification

The ARM Cortex-M4 is a 32-bit ARM processor core designed…

9 Min Read

Disabling All Interrupts on ARM Cortex-M0

The ARM Cortex-M0 is an extremely popular 32-bit embedded processor…

10 Min Read

What size instruction is the cortex M0?

The Cortex-M0 is a 32-bit ARM processor core designed for…

6 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account