mohitmishra786/low-level-dev-skills

low-power-embedded

Low-power embedded skill for sleep modes and energy optimization.

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill low-power-embedded

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

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)

ModeCPUPeripheralsRAMWake sourceRelative current
Runononon—highest
Sleepoffononany IRQmedium
Stopoffmost offonEXTI, RTC, UARTlow
Standbyoffofflost*WKUP pins, RTClowest

\* 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

SourceConfig
EXTI GPIOSYSCFG + EXTI IMR, edge trigger
RTC alarmRTC WUT/WAKEUP
UARTStart bit detection (some MCUs)
IWDGNot 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

SymptomCauseFix
Still mA in "sleep"Debug interface active (SWD)Disconnect debugger; disable DBGMCU
Immediate wake from WFIPending NVIC IRQClear flags before WFI
Lost state after wakeEntered Standby not StopUse Stop if RAM must persist
UART dead after wakeClock tree not restoredCall SystemInit() path
Higher than datasheet uAFloating GPIOSet 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
같은 저장소의 Skills

더 많은 Skills

모든 Skills
mohitmishra786
커뮤니티

core-dumps

Core dump analysis skill for production crash triage. Use when loading core files in GDB or LLDB, enabling core dump generation on Linux/macOS, mapping symbols with debuginfo or debuginfod, or extracting backtraces from crashes without re-running the program. Activates on queries about core files, ulimit, coredumpctl, debuginfod, crash triage, or analyzing segfaults from production binaries.

설치 수
2
GitHub Stars
267
업데이트
6월 27일
mohitmishra786
커뮤니티

custom-allocators

Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning jemalloc/mimalloc, writing Rust GlobalAlloc, or benchmarking allocator performance. Activates on queries about jemalloc, mimalloc, tcmalloc, arena allocator, GlobalAlloc, or fragmentation.

설치 수
2
GitHub Stars
267
업데이트
6월 27일
mohitmishra786
커뮤니티

ebpf

eBPF skill for Linux observability and networking. Use when writing eBPF programs with libbpf or bpftrace, attaching kprobes/tracepoints/XDP hooks, debugging verifier errors, working with eBPF maps, or achieving CO-RE portability across kernel versions. Activates on queries about eBPF, bpftool, bpftrace, XDP programs, libbpf, verifier errors, eBPF maps, or kernel tracing with BPF.

설치 수
2
GitHub Stars
267
업데이트
6월 27일
mohitmishra786
커뮤니티

flamegraphs

Flamegraph generation and interpretation skill. Use when converting perf, Valgrind Callgrind, or other profiler output into SVG flamegraphs using Brendan Gregg's FlameGraph tools, or when reading flamegraphs to identify performance bottlenecks. Activates on queries about flamegraphs, stackcollapse, flamegraph.svg, identifying hot frames, wide vs tall frames, or performance visualisation.

설치 수
2
GitHub Stars
267
업데이트
6월 27일