</>EmbeddedInterview

How do you design firmware and hardware for low power?

MediumElectronics & Hardware Basics

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

  1. Power budget: list every state, its current and time; compute the average and battery life.
  2. Clock tree: lower frequencies or voltage scaling for steady work; gate clocks of unused peripherals.
  3. Peripherals with DMA and low-power features (LPUART wake on character, ADC triggered by a low-power timer, comparator wake-up).
  4. RTOS tickless idle to avoid periodic wake-ups.
  5. 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).
  6. Radio: batch transmissions, use long connection intervals (BLE), sleep the radio.
  7. 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).