Topics / Electronics & Hardware Basics / Q17
How do you design firmware and hardware for low power?
Short answer: Average current is what drains the battery, so minimise the time spent awake and the current in each state: run fast and sleep (race to idle), use the deepest sleep mode that still meets wake-up latency and retention needs, switch off unused peripherals, clocks and external components, avoid polling, wake on interrupts or low-power timers, configure every GPIO (no floating inputs, no pull-ups fighting outputs), and measure the real current profile with a power analyser.
MCU power modes (typical Cortex-M)
| Mode | CPU | Clocks | RAM | Typical current | Wake-up |
|---|---|---|---|---|---|
| Run | on | all | yes | 50–200 µA/MHz | – |
| Sleep (WFI) | stopped | peripherals on | yes | ~30–50% of run | any interrupt, µs |
| Stop / deep sleep | stopped | high-speed clocks off, LSE/RTC on | yes | 1–10 µA | RTC, EXTI, LP UART, ~5–50 µs |
| Standby / shutdown | off | RTC only | lost (except backup) | 0.03–1 µA | reset-like boot, ms |
Checklist
- Power budget: list every state, its current and time; compute the average and battery life.
- Clock tree: lower frequencies or voltage scaling for steady work; gate clocks of unused peripherals.
- Peripherals with DMA and low-power features (LPUART wake on character, ADC triggered by a low-power timer, comparator wake-up).
- RTOS tickless idle to avoid periodic wake-ups.
- External components: power-gate sensors with a load switch; check regulator quiescent current, pull-up currents, LED indicators, voltage dividers (switch them off between measurements).
- Radio: batch transmissions, use long connection intervals (BLE), sleep the radio.
- Debug: the debugger keeps clocks running in sleep modes (disable DBGMCU low-power debug bits in production), and leaky GPIOs often account for the "missing" microamps.
Measuring: Nordic PPK2, Joulescope, Otii, or a shunt resistor with an oscilloscope; look at both the average and the peaks (battery internal resistance limits peak current, especially for coin cells).