Fix for PWM resume issue, SWINTEGRATION-57 #15139
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of changes
This is a workaround for the problem described here - #15135 (comment)
The PwmOut::resume() function in mbed-os/drivers/source/PwmOut.cpp sets the "percentage of the period" (the duty cycle) before it sets the period.
We capture the duty cycle in microseconds when the
PwmOut::write()->pwmout_write()
function is called. We do not update the duty cycle when thePwmOut::period_us()->pwmout_period_us()
function is called. Before this update, we didn't have the percent value to do so. With this update, the percent value is saved wheneverpwmout_write()
is called. And the percentage is used, when appropriate, in thepwmout_period_us()
function. If the duty cycle is updated with a time value before thepwmout_period_us()
function is called, that percentage will not be used.There are no Greentea or Unittest that cover this functionality. The problem can be observed on the output of the pin. This was manually tested by multiple team members at Infineon.
Impact of changes
Likely none. If there is an impact, it will be positive. The PWM signal will now be correct and as expected after
PwmOut::resume()
is called.Migration actions required
Not applicable
Documentation
None
Pull request type
Test results
Reviewers
@ARMMbed/team-cypress