aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoreZio Pan <[email protected]>2023-12-23 19:45:56 +0800
committereZio Pan <[email protected]>2023-12-23 19:53:02 +0800
commitdcd4e6384e3fab32809d01738ecd84011b4f0cc7 (patch)
tree81bcc8fcf6c177c5a20701642e76fd489fd91d56 /examples
parent2f75ffb2333904e1370a845ead88442c45b5ba5d (diff)
enable output compare preload for TIM
keep output waveform integrity
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32f4/src/bin/ws2812_pwm_dma.rs7
1 files changed, 7 insertions, 0 deletions
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 @@
21use embassy_executor::Spawner; 21use embassy_executor::Spawner;
22use embassy_stm32::gpio::OutputType; 22use embassy_stm32::gpio::OutputType;
23use embassy_stm32::pac; 23use embassy_stm32::pac;
24use embassy_stm32::pac::timer::vals::Ocpe;
24use embassy_stm32::time::khz; 25use embassy_stm32::time::khz;
25use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; 26use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm};
26use embassy_stm32::timer::{Channel, CountingMode}; 27use embassy_stm32::timer::{Channel, CountingMode};
@@ -89,6 +90,12 @@ async fn main(_spawner: Spawner) {
89 90
90 let pwm_channel = Channel::Ch1; 91 let pwm_channel = Channel::Ch1;
91 92
93 // PAC level hacking, enable output compare preload
94 // keep output waveform integrity
95 pac::TIM3
96 .ccmr_output(pwm_channel.index())
97 .modify(|v| v.set_ocpe(0, Ocpe::ENABLED));
98
92 // make sure PWM output keep low on first start 99 // make sure PWM output keep low on first start
93 ws2812_pwm.set_duty(pwm_channel, 0); 100 ws2812_pwm.set_duty(pwm_channel, 0);
94 101