Skip to content

Commit ce75aa5

Browse files
PWM: Fix an off-by-1 when computing ARR register
Fixes #48
1 parent d1ad94f commit ce75aa5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/timer/pwm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ macro_rules! pwm {
5656
rcc.rb.$apbXrstr.modify(|_, w| w.$timXrst().clear_bit());
5757
let ratio = rcc.clocks.apb_tim_clk / freq.into();
5858
let psc = (ratio - 1) / 0xffff;
59-
let arr = ratio / (psc + 1);
59+
let arr = ratio / (psc + 1) - 1;
6060
tim.psc.write(|w| unsafe { w.psc().bits(psc as u16) });
6161
tim.arr.write(|w| unsafe { w.$arr().bits(arr as u16) });
6262
$(

0 commit comments

Comments
 (0)