aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-05-19 14:41:44 +0000
committerGitHub <[email protected]>2023-05-19 14:41:44 +0000
commit9dff6b9d81a56966a815057c79898c178841b1cd (patch)
treedf30af461931c7d4f562af15883b7eeb6b7c076b /examples
parent464018e12db16f5926f49cfc8c348baee07f5fa7 (diff)
parentcd88e39f5fed0ed128f57d2e166f68a488e37698 (diff)
Merge #1419
1419: stm32/pwm: improve dead-time api r=Dirbaio a=xoviat Co-authored-by: xoviat <[email protected]>
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32f4/src/bin/pwm_complementary.rs31
1 files changed, 3 insertions, 28 deletions
diff --git a/examples/stm32f4/src/bin/pwm_complementary.rs b/examples/stm32f4/src/bin/pwm_complementary.rs
index 6e17f3fd3..a8a68ed6e 100644
--- a/examples/stm32f4/src/bin/pwm_complementary.rs
+++ b/examples/stm32f4/src/bin/pwm_complementary.rs
@@ -4,7 +4,7 @@
4 4
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::pwm::complementary_pwm::{Ckd, ComplementaryPwm, ComplementaryPwmPin}; 7use embassy_stm32::pwm::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin};
8use embassy_stm32::pwm::simple_pwm::PwmPin; 8use embassy_stm32::pwm::simple_pwm::PwmPin;
9use embassy_stm32::pwm::Channel; 9use embassy_stm32::pwm::Channel;
10use embassy_stm32::time::khz; 10use embassy_stm32::time::khz;
@@ -31,34 +31,9 @@ async fn main(_spawner: Spawner) {
31 khz(10), 31 khz(10),
32 ); 32 );
33 33
34 /*
35 Dead-time = T_clk * T_dts * T_dtg
36
37 T_dts:
38 This bit-field indicates the division ratio between the timer clock (CK_INT) frequency and the
39 dead-time and sampling clock (tDTS)used by the dead-time generators and the digital filters
40 (ETR, TIx),
41 00: tDTS=tCK_INT
42 01: tDTS=2*tCK_INT
43 10: tDTS=4*tCK_INT
44
45 T_dtg:
46 This bit-field defines the duration of the dead-time inserted between the complementary
47 outputs. DT correspond to this duration.
48 DTG[7:5]=0xx => DT=DTG[7:0]x tdtg with tdtg=tDTS.
49 DTG[7:5]=10x => DT=(64+DTG[5:0])xtdtg with Tdtg=2xtDTS.
50 DTG[7:5]=110 => DT=(32+DTG[4:0])xtdtg with Tdtg=8xtDTS.
51 DTG[7:5]=111 => DT=(32+DTG[4:0])xtdtg with Tdtg=16xtDTS.
52 Example if TDTS=125ns (8MHz), dead-time possible values are:
53 0 to 15875 ns by 125 ns steps,
54 16 us to 31750 ns by 250 ns steps,
55 32 us to 63us by 1 us steps,
56 64 us to 126 us by 2 us steps
57 */
58 pwm.set_dead_time_clock_division(Ckd::DIV1);
59 pwm.set_dead_time_value(0);
60
61 let max = pwm.get_max_duty(); 34 let max = pwm.get_max_duty();
35 pwm.set_dead_time(max / 1024);
36
62 pwm.enable(Channel::Ch1); 37 pwm.enable(Channel::Ch1);
63 38
64 info!("PWM initialized"); 39 info!("PWM initialized");