-
Notifications
You must be signed in to change notification settings - Fork 8.1k
drivers: counter: max32: Fix prescaler configuration #97711
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
drivers: counter: max32: Fix prescaler configuration #97711
Conversation
if (prescaler_index == 0) { | ||
tmr_cfg.pres = TMR_PRES_1; /* TMR_PRES_1 is 0 */ | ||
} else { | ||
/* TMR_PRES_2 is 1<<X */ | ||
tmr_cfg.pres = TMR_PRES_2 + (prescaler_index - 1); | ||
} |
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.
If i did not miss something, seems logic simply can be
tmr_cfg.pres = prescaler_index * TMR_PRES_2;
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.
You are right, thanks.
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.
Could you propagate it to pwm_max32.c ?
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.
Done.
a2a8a80
to
2267dc4
Compare
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.
This part of the commit message needs to be updated or removed:
Add prescaler enums into a lookup table and set
counter prescaler from this array using prescaler_index parameter.
Otherwise LGTM
The existing formula assumed prescaler enumerations were consecutive, which led to incorrect values being passed to HAL functions. Update the code to calculate correct prescaler enumerations. Signed-off-by: Furkan Akkiz <[email protected]>
Replace the look-up table used to obtain the prescaler enumeration with a simple multiplication. Signed-off-by: Tahsin Mutlugun <[email protected]>
2267dc4
to
5902b57
Compare
Commit message has been fixed and the change has been propagated to |
|
Fixes a bug in the prescaler configuration formula. Prescaler enumerations are not consecutive numbers, so the existing formula does not work as expected.
Add prescaler enums into a lookup table and set counter prescaler from this array using prescaler_index parameter.This is the same fix introduced in #95409, but for the counter driver.