enable output compare preload for TIM
keep output waveform integrity
This commit is contained in:
parent
2f75ffb233
commit
dcd4e6384e
1 changed files with 7 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue