diff --git a/examples/stm32f4/src/bin/ws2812_pwm_dma.rs b/examples/stm32f4/src/bin/ws2812_pwm_dma.rs index c4181d024..cdce36f2e 100644 --- a/examples/stm32f4/src/bin/ws2812_pwm_dma.rs +++ b/examples/stm32f4/src/bin/ws2812_pwm_dma.rs @@ -21,6 +21,7 @@ use embassy_executor::Spawner; use embassy_stm32::gpio::OutputType; use embassy_stm32::pac; +use embassy_stm32::pac::timer::vals::Ocpe; use embassy_stm32::time::khz; use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; use embassy_stm32::timer::{Channel, CountingMode}; @@ -89,6 +90,12 @@ async fn main(_spawner: Spawner) { let pwm_channel = Channel::Ch1; + // PAC level hacking, enable output compare preload + // keep output waveform integrity + pac::TIM3 + .ccmr_output(pwm_channel.index()) + .modify(|v| v.set_ocpe(0, Ocpe::ENABLED)); + // make sure PWM output keep low on first start ws2812_pwm.set_duty(pwm_channel, 0);