Skip to content

Commit d0c0aa3

Browse files
bors[bot]burrbull
andauthored
Merge #518
518: fix PwmHz::get_period r=therealprof a=burrbull See stm32-rs/stm32f1xx-hal#434 Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2 parents 568d37f + a85eb5a commit d0c0aa3

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Changed
1111

12+
- `PwmHz::get_period`: fix computation of return value, prevent division by zero
1213
- apply #[inline] attribute to bitbanding functions [#517]
1314
- update `stm32f4` to 0.15.1 [#481]
1415
- use `stm32_i2s_v12x` version 0.3, reexport it, and implements requirement for it [#490]

src/timer/pwm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ where
301301
let arr = TIM::read_auto_reload();
302302

303303
// Length in ms of an internal clock pulse
304-
clk / (psc * arr)
304+
clk / ((psc + 1) * (arr + 1))
305305
}
306306

307307
pub fn set_period(&mut self, period: Hertz) {

0 commit comments

Comments
 (0)