-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix issue #5119, changed pwmout_api. #7716
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
Conversation
The period of pwm we could get was limited to 69.9 ms, because prescaler value was set once only during initialization. base->mod is a 16 bit register, to get longer period we have to slow down the clk.
pwm_base_clock = CLOCK_GetFreq(kCLOCK_BusClk); | ||
pwm_clock_mhz = (float)pwm_base_clock / 1000000.0f; | ||
uint32_t mod = (pwm_clock_mhz*(float)us) - 1; | ||
while(mod > 0xFFFF){ |
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 is target code but should be same as the rest of the code here, see https://os.mbed.com/docs/latest/reference/style.html
spaces around operators and while ()
, etc. Please fix
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_clock_mhz * (float)us
spaces around operators, same for line 135
@0xc0170 formatting updated |
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.
Thanks for the patch
Interesting. I'm good with the change, since imo most common applications set a fixed frequency instead of duty cycle. @ARMmbed/mbed-os-hal Care to take a quick look? /morph build |
Build : SUCCESSBuild number : 2799 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2429 |
/morph test |
/morph mbed2-build |
Test : SUCCESSBuild number : 2531 |
Fix issue ARMmbed#5119, changed pwmout_api.
Description
K64F was not able to generate pwm with 100 ms long period. This PR fix the problem, by computing and setting the optimal prescaler value while setting the pwm period. This way we also don't lose accuracy for short periods, but it is even enhanced a little.
Pull request type