Skip to main content
skill CX Codex

low-power-embedded — Claude Code skill: sleep modes and energy

low-power-embedded — a skill for configuring MCU low-power modes: sleep, stop, standby, peripheral clock gating, and wake-up sources. Activates on questions about WFI, STOP mode, STM32 PWR, nRF sleep, or reducing firmware power draw.

MIT 397 installs ★ 298 updated 2026-06-27

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mohitmishra786/low-level-dev-skills --skill low-power-embedded -a claude-code
Open on GitHub

What low-power-embedded does

The skill walks through the power mode hierarchy: Sleep turns off the CPU but keeps peripherals and RAM active; Stop disables most subsystems while preserving memory; Standby minimizes power at the cost of losing state. It provides Cortex-M code for WFI and WFE instructions, STM32-specific patterns using PWR and RCC registers, and guidance on configuring EXTI and RTC as wake sources.

Includes a peripheral clock gating checklist, a troubleshooting table (device won't wake, measured current exceeds datasheet specs, state lost after resuming from sleep), and cross-references with related skills—interrupt handling, GPIO configuration, timers, and FreeRTOS tickless idle. Exiting Stop mode requires reinitializing the clock tree and peripheral registers because most MCUs lose register state in this mode.

What it helps with

  • Reduce idle current consumption in microcontroller sleep modes
  • Configure wake-up with minimal latency using EXTI or RTC
  • Gate clocks to unused peripherals and bus domains
  • Debug a device stuck in sleep or failing to resume
  • Measure and compare actual current draw to datasheet

Example prompts for the agent

  • Configure STM32 Stop mode with EXTI0 wake-up and PLL restore sequence
  • Help me enter Sleep mode while clearing all interrupt flags before WFI
  • Show how to disable GPIO clock gating when entering standby

How to install low-power-embedded

1Skills CLI (Vercel)

npx skills add mohitmishra786/low-level-dev-skills --skill low-power-embedded -a claude-code

2Manually: put the files in place

~/.claude/skills/low-power-embedded/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/low-power-embedded/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about low-power-embedded

How do I install low-power-embedded for Claude Code?

Run npx skills add mohitmishra786/low-level-dev-skills --skill low-power-embedded -a claude-code in the terminal, then check ~/.claude/skills/low-power-embedded/SKILL.md.

What does the low-power-embedded skill do?

It guides you through MCU low-power mode setup: choosing between Sleep, Stop, and Standby, turning off peripheral clocks, configuring wake-up sources via EXTI or RTC, and measuring power consumption.

When does this skill activate automatically?

When you ask about WFI, STOP mode, STM32 PWR, nRF sleep, EXTI as a wake source, or reducing embedded system power draw.

Source text

SKILL.md · MIT
---
name: low-power-embedded
description: Low-power embedded skill for sleep modes and energy optimization. Use when configuring MCU sleep/stop/standby, peripheral clock gating, wake-up sources, or measuring firmware current draw. Activates on queries about WFI, STOP mode, STM32 PWR, nRF sleep, wake-up EXTI, or reducing embedded power consumption.
---

# Low-Power Embedded

## Purpose

Guide agents through MCU low-power modes: sleep vs deep sleep (stop/standby), peripheral and bus clock gating, wake-up source configuration, and practical current measurement — with Cortex-M `WFI`/`WFE` and vendor PWR examples (STM32-focused patterns apply broadly).

## When to Use

- Battery-powered firmware missing power budget
- Wake-up latency vs consumption tradeoffs
- Debugging "device won't wake" or "current still mA in sleep"
- Before shipping RTOS idle hook or bare-metal main loop sleep
- Cross-linking with `skills/baremetal/interrupts-and-exceptions-baremetal`

## Workflow

### 1. Power mode hierarchy (STM32-style)

| Mode | CPU | Peripherals | RAM | Wake source | Relative current |
|------|-----|-------------|-----|-------------|------------------|
| Run | on | on | on | — | highest |
| Sleep | off | on | on | any IRQ | medium |
| Stop | off | most off | on | EXTI, RTC, UART | low |
| Standby | off | off | lost* | WKUP pins, RTC | lowest |

\* Standby clears most SRAM; use backup domain or external EEPROM for state.

### 2. Enter Sleep (WFI)

```c
/* Cortex-M — sleep until interrupt */
__disable_irq();
/* configure wake source (e.g. EXTI, RTC alarm) */
__enable_irq();
__WFI(); /* or __WFE() for event-based wake */
```

Ensure pending interrupts are cleared before `WFI` or wake may be immediate.

### 3. STM32 Stop mode pattern

```c
#include "stm32f4xx.h"

void enter_stop_mode(void)
{
    /* Gate clocks you do not need */
    RCC->AHB1ENR &= ~RCC_AHB1ENR_GPIOAEN; /* example — only if safe */

    PWR->CR |= PWR_CR_CWUF;   /* clear wake flags */
    PWR->CR |= PWR_CR_PDDS;   /* deep sleep = Stop */
    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;

    __WFI();

    /* After wake: re-enable HSE/PLL — clocks lost in Stop on many parts */
    SystemInit();
}
```

After Stop, re-init clocks and peripherals that lost their registers.

### 4. Clock gating checklist

```
Before sleep
├── Disable unused peripheral clocks (RCC xENR)
├── Disable ADC/DAC continuous modes
├── Stop DMA channels
├── Enter peripheral low-power (UART mute, SPI off)
└── Configure lowest viable regulator scale (Voltage Scale 2/3)
```

### 5. Wake-up sources

| Source | Config |
|--------|--------|
| EXTI GPIO | SYSCFG + EXTI IMR, edge trigger |
| RTC alarm | RTC WUT/WAKEUP |
| UART | Start bit detection (some MCUs) |
| IWDG | Not a wake source — resets device |

### 6. Measurement tips

- Use ammeter in series with VDDA/VDD; short sampling window for uA
- DWT cycle counter for wake latency benchmarking
- Compare run vs sleep current **with same clock tree** documented

### 7. RTOS note

FreeRTOS `configUSE_TICKLESS_IDLE` maps to WFI/Stop — coordinate with `skills/embedded/freertos`.

### 8. Agent usage

```
/low-power-embedded Configure STM32 Stop mode with EXTI0 wake and PLL restore
```

## Common Problems

| Symptom | Cause | Fix |
|---------|-------|-----|
| Still mA in "sleep" | Debug interface active (SWD) | Disconnect debugger; disable DBGMCU |
| Immediate wake from WFI | Pending NVIC IRQ | Clear flags before WFI |
| Lost state after wake | Entered Standby not Stop | Use Stop if RAM must persist |
| UART dead after wake | Clock tree not restored | Call `SystemInit()` path |
| Higher than datasheet uA | Floating GPIO | Set unused pins analog or pull |

## Related Skills

- `skills/baremetal/interrupts-and-exceptions-baremetal` — EXTI wake IRQs
- `skills/baremetal/gpio-baremetal` — pin mode for leakage control
- `skills/baremetal/stm32-baremetal` — RCC and PWR registers
- `skills/baremetal/timers-pwm-baremetal` — stop timers before sleep
- `skills/embedded/freertos` — tickless idle integration

© mohitmishra786 · MIT · mohitmishra786/low-level-dev-skills

Similar skills

All skills for Programming languages →

From the same set140

The whole set →
interrupts-and-exceptions-baremetal interrupts-and-exceptions-baremetal guides coding agents through Cortex-M NVIC setup, non-blocking ISR design, and HardFault debugging. Useful when building bare-metal firmware without an RTOS. CX Codex +1 403installs compiler-optimizations-deep compiler-optimizations-deep explains vectorization failures, register spills, and profiling pipelines with PGO or BOLT when default -O3 flags fail to optimize critical C and C++ loops. CX Codex +1 402installs kernel-internals kernel-internals guides AI agents through Linux memory allocators, CFS and EEVDF schedulers, and VFS internals. Useful when tracking allocation failures or tuning kernel caches. CX Codex +1 399installs cpu-pipelines-and-hazards cpu-pipelines-and-hazards walks through CPU pipeline stages, data and control hazards, forwarding and stalls. Useful when a hot loop slows down and the reason is not obvious. CX Codex +1 398installs bootloaders-embedded bootloaders-embedded is a skill for Cortex-M bootloader development. It covers image validation, safe handoff to an app, vector table relocation, and updates over UART or USB DFU. CX Codex +1 395installs kernel-debugging This Claude Code skill guides Linux kernel debugging with tracing, debuggers, and crash-dump analysis. It activates for questions about kgdb, kdb, ftrace, kprobes, dyndbg, kdump, or dmesg levels. CX Codex +1 395installs qemu-kvm qemu-kvm walks the agent through QEMU VMs with KVM acceleration: flags, virtio devices, VFIO passthrough and booting custom kernels. CX Codex +1 395installs baremetal-startup baremetal-startup is a Claude Code skill that guides coding agents through Cortex-M and RISC-V initialization from reset to main(). CX Codex +1 394installs

Project sponsors

Companies that keep this analytics open