-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Incorrect pwm frequency #205
Comments
Note that center align modes will also cause incorrect freqs. |
I have not had the time to dig into the PWM issues / PRs yet, but can this possible resolved or improved by #196? |
Looks like current PWM and Timer implementation is wrong at source clock calculation. Lines 283 to 284 in f8eb292
|
As in, some timers use apb1 while others use apb2? Here's how I solved it, where paste! {
let mut timer = Timer { clock_speed: clocks.[<$apb _timer>](), tim };
// ...
} Example trait implementation: fn apb2_timer(&self) -> u32 {
if let ApbPrescaler::Div1 = self.apb2_prescaler {
self.apb2()
} else {
self.apb2() * 2
}
} |
tim1(dp.TIM1, 144, 1.mhz().into(), &clocks)
leads to actual timer frequency of 0.5 MHz, as code doesn't set/takes into account
tim1sw
bit inRCC
CFGR3
registerSame thing with other timers and possibly peripherals most likely. (Occurs only when MCU is running with max frequency)
The text was updated successfully, but these errors were encountered: