-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add more methods to Pwm<T> #140
base: main
Are you sure you want to change the base?
Conversation
src/timer/pwm.rs
Outdated
$( | ||
self.tim.arr.modify(|_, w| w.$arr_h().bits((arr >> 16) as u16)); | ||
self.tim.arr.modify(|_, w| w.$arr_h().bits((period >> 16) as u16)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pwm! {
TIM1: (tim1, arr),
TIM3: (tim3, arr_l, arr_h), // should this really have a `arr_h`?
TIM14: (tim14, arr),
TIM16: (tim16, arr),
TIM17: (tim17, arr),
}
I must say that I am a bit confused about the 16/32bit for TIM3. From what I understand from the reference manual for g0x0 TIM3 is just 16-bit. reference manual for g0x1 says pretty much the same thing except it adds a TIM2 which is 32-bit.
Looking at the pac, TIM3 does have an arr_h
(inherited from tim2?), same thing when looking in the reference manual...
Also is it really safe to write to arr
in two steps without the pwm signal going crazy in between the stores?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct me if I am wrong but from what I can gather, TIM3 is 16bits but does share the same memory config structure as TIM2(which is 32bit)
Hi :)
I have a use case where I need to update the frequency of several pwm outputs very often, therefore I need access to directly setting the period and/or prescaler registers. This PR does that plus some extra methods like start/pause, and access to setting the prescaler.