This repository was archived by the owner on Apr 16, 2021. It is now read-only.
analogWrite with negative value to delete pwm objects #105
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.
This commit allows to deactivate an active PWM attached to a pin N by passing a negative value to the function
analogWrite(N, value)
.Necessary fix in mbed-os:
Because of how this mbed function is implemented, there is the need to add a piece of code that sets
nordic_internal_pwm[index] == NC
when an active pwm is deinitialized (see here ). Otherwise, after having initialized all the 4 pwm instances, thenordic_internal_pwm
array will be full. At this point, when a pwm is deactivated, its entry in the array will not be cleared. This is a problem because in this way when a new pwm is initialized, here, no pwm instance will be found free and the default instance (the last one) will be returned. This means that no matter what pwm is deactivated, the new init pwm will try to use the default pwm instance even if it is not free. This results in a failure.test sketch: