Overview
Curated: · Written: · Reviewed:
Power Management & Low-Power Design
In one line
Battery life is set by how long the device spends in each sleep state, what each transition costs, and which wake source survives the state you choose. Reach for it whenever a design has long idle gaps and a fixed battery budget.
Key definitions
- State retention: what a sleep state keeps powered (SRAM, registers, backup domain). It decides whether you resume in place or re-initialize.
- Transition cost: the charge and time to enter and exit a state. It is why the deepest state loses on short gaps.
- Break-even time: the idle length at which a state starts to save energy.
- Wake source: a peripheral or event that stays powered and clocked in the chosen state.
- Lost wakeup: an event that arrives between the work check and WFI and is never serviced.
- Usage count: outstanding clients that need a runtime-PM device active. Every get is paired with a put, on error paths too.
Formulas and complexity
Q_transition is the charge spent per transition in coulombs, and the energy term is E_transition = V × Q_transition at the supply voltage. Battery life is usable capacity divided by I_avg, after derating for temperature, cutoff voltage and converter efficiency.
How it works
Energy is state power times residence time, plus the cost of every transition. Before choosing a state, predict the idle gap and compare it with the state's break-even time. Entry is a race: mask the producer interrupt, re-read the work flag, then execute WFI with a wake source that is enabled and powered in the target state. A pending enabled interrupt wakes WFI even when PRIMASK masks its handler, so the handler runs after wake only if it is unmasked. On wake, restore clocks, then peripherals, then DMA, before any consumer runs.
When to use and when not to
| Condition | Favours a deeper state | Favours a shallower state |
|---|---|---|
| Expected idle | Well past break-even | Shorter than break-even |
| Next deadline | Wake latency fits the deadline | Wake latency exceeds the deadline |
| State data | Can be re-initialized after wake | Must resume in place |
| Wake source | Powered and clocked in the state | Needs a clock the state gates |
| Peripheral activity | Quiesced, DMA complete, cache maintained | Transfer or radio event pending |
Traps interviewers probe
- "The deepest state is cheapest." Compute break-even first. With an 18 µC transition, 8.4 mA run current and 2.1 µA stop current, break-even is 18 µC / (8.4 mA − 2.1 µA) ≈ 2.14 ms, so a 200 µs gap stays in Sleep.
- "WFI saves power, so just WFI." WFI only suspends instruction execution. Mask the producer, re-read the flag, then sleep. Marking the flag volatile does not close the race.
- "2.1 µA means capacity divided by 2.1 µA." The figure is measured at 25 °C with peripherals off. Measure or derate at the deployment temperature and voltage.
- "The watchdog sleeps too." Independent watchdogs often keep running in Stop. A 4 s IWDG with a 30 s advertising interval resets the part unless it is fed from an RTC wakeup or reprogrammed.
- "The multimeter confirms the budget." A DMM averages away wake transients and inrush. Use an auto-ranging power profiler sampling at 100 kHz or more, triggered by a firmware GPIO marker.
Interview tips
Open with the model: "Energy is state power times time plus transition cost, so I compute break-even per state against the idle distribution before choosing."
Expect this chain of follow-ups: break-even, then wake latency against the deadline, then retained state, then the wake-source matrix, then the measurement setup, then temperature and voltage corners. Have an answer for each link.
30-second outline:
- State the energy model and what the idle gaps look like.
- Give break-even for the candidate states and say which gap lengths fall on each side.
- Name the wake source that stays powered in the chosen state, and check its latency against the next deadline.
- Say what state data is lost, and how resume restores it.
- Say how you would measure it, and at which temperature and voltage.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.