From ae3eb30f28265d99fed738a23d5f2ad4d77677e1 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 16 Nov 2025 17:14:31 -0500 Subject: [PATCH] stm32: Enable MOE bit in hard_pwm.c for all stm32 chips Always enable the MOE bit. Reported by @tt33415366. Signed-off-by: Kevin O'Connor --- src/stm32/hard_pwm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/stm32/hard_pwm.c b/src/stm32/hard_pwm.c index 72c7685bd..f4c8cdfde 100644 --- a/src/stm32/hard_pwm.c +++ b/src/stm32/hard_pwm.c @@ -400,11 +400,14 @@ gpio_timer_setup(uint8_t pin, uint32_t cycle_time, uint32_t val, default: shutdown("Invalid PWM channel"); } + // Enable PWM output p->timer->CR1 |= TIM_CR1_CEN; -#if CONFIG_MACH_STM32H7 || CONFIG_MACH_STM32G0 - p->timer->BDTR |= TIM_BDTR_MOE; -#endif + + // Advanced timers need MOE enabled. On standard timers this is a + // write to reserved memory, but that seems harmless in practice. + p->timer->BDTR = TIM_BDTR_MOE; + return channel; }