0
0
ARM Architectureknowledge~5 mins

Sleep mode (WFI instruction) in ARM Architecture

Choose your learning style9 modes available
Introduction

The WFI instruction helps the processor save power by pausing its work until something important happens.

When the processor has no tasks to do and wants to save battery.
In embedded devices like smart watches to extend battery life.
During waiting periods in a program, like waiting for a button press.
In low-power modes of microcontrollers to reduce energy use.
When the system is idle but needs to wake up quickly on an event.
Core Concept
ARM Architecture
WFI

WFI stands for 'Wait For Interrupt'.

It tells the CPU to stop executing instructions until an interrupt occurs.

Key Points
This simple instruction puts the CPU into sleep mode until an interrupt wakes it.
ARM Architecture
WFI
In C code for ARM, this inline assembly calls the WFI instruction.
ARM Architecture
asm volatile ("WFI");
Detailed Explanation

This program runs some tasks, then uses WFI to sleep until an interrupt happens. After waking, it repeats the process.

ARM Architecture
/* Example in ARM assembly */

start:
    /* Do some work here */
    
    /* Enter sleep mode to save power */
    WFI

    /* After waking up, continue work */
    B start
OutputSuccess
Important Notes

WFI only pauses the CPU, peripherals can still run and generate interrupts.

Not all interrupts wake the CPU; some may be masked or disabled.

Using WFI helps reduce power consumption in battery-powered devices.

Summary

WFI instruction puts the CPU into a low-power sleep mode.

The CPU wakes up when an interrupt occurs.

It is useful for saving energy during idle times.