Skip to content

Commit 52c8119

Browse files
committed
Fix more code not matching comment in deadtime example
1 parent a8ce372 commit 52c8119

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

examples/hrtim/deadtime.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,29 @@ fn main() -> ! {
4949
let prescaler = Pscl1;
5050

5151
let gpioa = dp.GPIOA.split(&mut rcc);
52-
let pin_a = gpioa.pa8; // D7 On nucleo-G474 - LI Blue-White
53-
let pin_b = gpioa.pa9; // D8 On nucleo-G474 - HI Green
52+
let pin_a = gpioa.pa8; // D7 On nucleo-G474
53+
let pin_b = gpioa.pa9; // D8 On nucleo-G474
5454

55-
// . . . .
56-
// . 30% . . .
57-
// ---- . .---- .
58-
//out1 | | . | | .
59-
// | | . | | .
60-
// -------- ---------------------------- --------------------
61-
// . .---- . .----
62-
//out2 . | | . | |
63-
// . | | . | |
64-
// ------------------------ ---------------------------- ----
65-
// . . . .
66-
// . . . .
55+
// . . .
56+
// .duty . .
57+
// ---- .---- .
58+
//out1 | | | | .
59+
// | | | | .
60+
// -------- ------------ -----------.
61+
// . ------ ------ .
62+
//out2 . | | | | .
63+
// . | | | | .
64+
// --------------- ---------- --.
65+
// . |<>| |<>| .
66+
// . 33ns 33ns .
6767
let (hr_control, ..) = dp.HRTIM_COMMON.hr_control(&mut rcc).wait_for_calibration();
6868
let mut hr_control = hr_control.constrain();
6969

7070
let deadtime = DeadtimeConfig::default()
7171
.prescaler(stm32_hrtim::deadtime::DeadtimePrescaler::ThrtimDiv8)
7272
.deadtime_rising_value(32) // 32 / (8 * 120MHz) = ~33.33ns
7373
.deadtime_falling_value(32); // 32 / (8 * 120MHz) = ~33.33ns
74-
let period = 0xF00;
74+
let period = 0xF00; // (120MHz * 32) / 0xF00 = 1MHz
7575
let HrParts {
7676
mut timer,
7777
mut cr1,
@@ -81,7 +81,7 @@ fn main() -> ! {
8181
.HRTIM_TIMA
8282
.pwm_advanced((pin_a, pin_b))
8383
.prescaler(prescaler)
84-
.period(period) // (120MHz * 32) / 0xF00 = 1MHz
84+
.period(period)
8585
.deadtime(deadtime)
8686
.out1_polarity(stm32_hrtim::Polarity::ActiveHigh)
8787
.out2_polarity(stm32_hrtim::Polarity::ActiveHigh)
@@ -98,7 +98,7 @@ fn main() -> ! {
9898
timer.start(&mut hr_control.control);
9999

100100
loop {
101-
// Step frequency from 14.6kHz to about 146kHz(half of that when only looking at one pin)
101+
// Step duty cycle from 10% to 90%
102102
for i in 1..10 {
103103
let p = timer.get_period();
104104
info!("p: {}", p);

0 commit comments

Comments
 (0)