stm32/pwm: improve dead-time api
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
|
||||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::pwm::complementary_pwm::{Ckd, ComplementaryPwm, ComplementaryPwmPin};
|
||||
use embassy_stm32::pwm::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin};
|
||||
use embassy_stm32::pwm::simple_pwm::PwmPin;
|
||||
use embassy_stm32::pwm::Channel;
|
||||
use embassy_stm32::time::khz;
|
||||
@ -31,34 +31,9 @@ async fn main(_spawner: Spawner) {
|
||||
khz(10),
|
||||
);
|
||||
|
||||
/*
|
||||
Dead-time = T_clk * T_dts * T_dtg
|
||||
|
||||
T_dts:
|
||||
This bit-field indicates the division ratio between the timer clock (CK_INT) frequency and the
|
||||
dead-time and sampling clock (tDTS)used by the dead-time generators and the digital filters
|
||||
(ETR, TIx),
|
||||
00: tDTS=tCK_INT
|
||||
01: tDTS=2*tCK_INT
|
||||
10: tDTS=4*tCK_INT
|
||||
|
||||
T_dtg:
|
||||
This bit-field defines the duration of the dead-time inserted between the complementary
|
||||
outputs. DT correspond to this duration.
|
||||
DTG[7:5]=0xx => DT=DTG[7:0]x tdtg with tdtg=tDTS.
|
||||
DTG[7:5]=10x => DT=(64+DTG[5:0])xtdtg with Tdtg=2xtDTS.
|
||||
DTG[7:5]=110 => DT=(32+DTG[4:0])xtdtg with Tdtg=8xtDTS.
|
||||
DTG[7:5]=111 => DT=(32+DTG[4:0])xtdtg with Tdtg=16xtDTS.
|
||||
Example if TDTS=125ns (8MHz), dead-time possible values are:
|
||||
0 to 15875 ns by 125 ns steps,
|
||||
16 us to 31750 ns by 250 ns steps,
|
||||
32 us to 63us by 1 us steps,
|
||||
64 us to 126 us by 2 us steps
|
||||
*/
|
||||
pwm.set_dead_time_clock_division(Ckd::DIV1);
|
||||
pwm.set_dead_time_value(0);
|
||||
|
||||
let max = pwm.get_max_duty();
|
||||
pwm.set_dead_time(max / 1024);
|
||||
|
||||
pwm.enable(Channel::Ch1);
|
||||
|
||||
info!("PWM initialized");
|
||||
|
Reference in New Issue
Block a user