/timers-pwm-baremetal
Bare-metal timer and PWM skill. Use when configuring general-purpose timers for PWM, input capture, or periodic ticks without RTOS. Activates on queries about timer prescaler, PWM duty cycle, input capture, or SysTick bare-metal.
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill timers-pwm-baremetal --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/timers-pwm-baremetal
Context preview
The summary Claude sees to decide when to auto-load this skill.
Bare-metal timer and PWM skill. Use when configuring general-purpose timers for PWM, input capture, or periodic ticks without RTOS. Activates on queries about timer prescaler, PWM duty cycle, input capture, or SysTick bare-metal.
SKILL.md
timers-pwm-baremetal.SKILL.mdname: timers-pwm-baremetal
description: Bare-metal timer and PWM skill. Use when configuring general-purpose timers for PWM, input capture, or periodic ticks without RTOS. Activates on queries about timer prescaler, PWM duty cycle, input capture, or SysTick bare-metal.
Timers and PWM (Bare-Metal)
Purpose
Configure MCU timers for PWM output, input capture, and periodic scheduling: prescaler/ARR setup, compare channels, and SysTick as a simple tick source.
When to Use
- Motor/LED dimming via PWM
- Measuring pulse width (input capture)
- Bare-metal `millis()` without FreeRTOS
- Hardware periodic sampling trigger
Workflow
1. PWM on TIM2 CH1 (STM32)
f_pwm = f_timer_clk / ((PSC+1) * (ARR+1))
duty = (CCR / (ARR+1)) * 100%
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
TIM2->PSC = 83; /* 84MHz / 84 = 1 MHz tick */
TIM2->ARR = 999; /* 1 kHz PWM */
TIM2->CCR1 = 500; /* 50% duty */
TIM2->CCMR1 |= (6U << TIM_CCMR1_OC1M_Pos); /* PWM mode 1 */
TIM2->CCER |= TIM_CCER_CC1E;
TIM2->CR1 |= TIM_CR1_CEN;
GPIO: PA0 AF1 TIM2_CH1.
2. SysTick tick
volatile uint32_t tick_ms;
void SysTick_Handler(void) {
tick_ms++;
}
void systick_init(uint32_t hz) {
SysTick_Config(SystemCoreClock / hz);
}3. Input capture
Configure channel in `CCMR` as input, set `CCER` polarity, read `CCR` on interrupt when edge captured.
4. Agent usage
/timers-pwm-baremetal 1 kHz 25% duty PWM on TIM2 channel 1
Common Problems
| Symptom | Cause | Fix | |---------|-------|-----| | Wrong frequency | APB timer clock doubling | Check RM timer clock x2 rule | | No PWM output | CCER/CCMR not enabled | Enable channel output | | Jittery tick | SysTick overridden | One owner for SysTick |
Related Skills
- `skills/baremetal/gpio-baremetal` — timer pin AF
- `skills/embedded/freertos` — replace SysTick with RTOS tick
- `skills/baremetal/adc-dac-baremetal` — timer TRGO for ADC trigger
Read more
name: timers-pwm-baremetal description: Bare-metal timer and PWM skill. Use when configuring general-purpose timers for PWM, input capture, or periodic ticks without RTOS. Activates on queries about timer prescaler, PWM duty cycle, input capture, or SysTick bare-metal.
Timers and PWM (Bare-Metal)
Purpose
Configure MCU timers for PWM output, input capture, and periodic scheduling: prescaler/ARR setup, compare channels, and SysTick as a simple tick source.
When to Use
- Motor/LED dimming via PWM
- Measuring pulse width (input capture)
- Bare-metal `millis()` without FreeRTOS
- Hardware periodic sampling trigger
Workflow
1. PWM on TIM2 CH1 (STM32)
f_pwm = f_timer_clk / ((PSC+1) * (ARR+1)) duty = (CCR / (ARR+1)) * 100%
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; TIM2->PSC = 83; /* 84MHz / 84 = 1 MHz tick */ TIM2->ARR = 999; /* 1 kHz PWM */ TIM2->CCR1 = 500; /* 50% duty */ TIM2->CCMR1 |= (6U << TIM_CCMR1_OC1M_Pos); /* PWM mode 1 */ TIM2->CCER |= TIM_CCER_CC1E; TIM2->CR1 |= TIM_CR1_CEN;
GPIO: PA0 AF1 TIM2_CH1.
2. SysTick tick
volatile uint32_t tick_ms;
void SysTick_Handler(void) {
tick_ms++;
}
void systick_init(uint32_t hz) {
SysTick_Config(SystemCoreClock / hz);
}3. Input capture
Configure channel in `CCMR` as input, set `CCER` polarity, read `CCR` on interrupt when edge captured.
4. Agent usage
/timers-pwm-baremetal 1 kHz 25% duty PWM on TIM2 channel 1
Common Problems
| Symptom | Cause | Fix | |---------|-------|-----| | Wrong frequency | APB timer clock doubling | Check RM timer clock x2 rule | | No PWM output | CCER/CCMR not enabled | Enable channel output | | Jittery tick | SysTick overridden | One owner for SysTick |
Related Skills
- `skills/baremetal/gpio-baremetal` — timer pin AF
- `skills/embedded/freertos` — replace SysTick with RTOS tick
- `skills/baremetal/adc-dac-baremetal` — timer TRGO for ADC trigger
A curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.
Repo: mohitmishra786/low-level-dev-skills
Other skills on low-level-dev-skills.
- /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,
Open skill - /numa-programming
NUMA programming skill for multi-socket memory locality. Use when detecting NUMA topology, binding processes with numactl, using libnuma API, building NUMA-aware data structures, or measuring remote access penalties. Activates on queries about numactl, libnuma, NUMA topology,
Open skill - /af-xdp
AF_XDP skill for high-performance XDP sockets. Use when creating AF_XDP sockets, configuring UMEM and XSK rings, XDP_REDIRECT programs, copy vs zero-copy mode, or comparing with DPDK. Activates on queries about AF_XDP, xsk_umem, XDP_REDIRECT, libbpf xsk, or zero-copy XDP.
Open skill - /dpdk
DPDK skill for userspace packet I/O. Use when initializing EAL, configuring PMD drivers, using mbuf pools and rte_ring, setting up huge pages, RSS, or testpmd validation. Activates on queries about DPDK, EAL, rte_eth_rx_burst, hugepages, PMD, or testpmd.
Open skill - /io-uring
io_uring skill for Linux async I/O. Use when building high-performance servers with liburing, multi-shot operations, provided buffers, fixed files, zero-copy send, or tokio-uring. Activates on queries about io_uring, SQE/CQE, liburing, IORING_OP_PROVIDE_BUFFERS, or io_uring vs
Open skill - /adc-dac-baremetal
Bare-metal ADC and DAC skill. Use when configuring analog sampling, DMA-driven ADC, calibration, or DAC output on MCUs. Activates on queries about ADC bare-metal, sampling time, DMA ADC, or DAC channel setup.
Open skill

