-
Notifications
You must be signed in to change notification settings - Fork 231
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 function to enable multiple PWM slices at the same time #668
Add function to enable multiple PWM slices at the same time #668
Conversation
This is needed to be able to have e.g. 3 PWM slices that are in phase, but may use different duty cycles. Example usage: `pwm_slices.enable_simultaneous(0b0000_0111);`
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.
Thank you for your contribution.
I would've expected to find this as a type-level slice group operation.
This would save one to have to figure the right bit pattern.
Also, don't we need a way do synchronously disable them as well?
I agree that the API could be more user friendly. However, as I have no idea how much effort such a better API would be, I wouldn't reject this simple API.
Not necessarily. The reason for synchronously enabling the signals is not to avoid a few cycles of delay between them becoming active, but to make sure the pulses are in phase. That's not an issue when turning the signals off. |
It is possible to implement a function without a bit pattern parameter like this:
with
However I think that it's still not a nice API, because you need references to both |
I can't tell the difference between the two photos, but the diff looks OK to me. |
@thejpster ah, I should have explained the pictures better. The purple square wave is not centered (exactly in phase) within the cyan square wave. In the first picture, the purple is a little bit to the right, but in the second image, it is perfectly in the center of the cyan square wave. (because in the second picture, this feature was used to start the square waves in an atomic operation. Perhaps this part of the first image explains it best, that the purple square wave are not in phase. |
I placed this in milestone 0.10.0 for now, just to make it obvious that 0.9.0 doesn't need to wait for this PR. It's not a breaking change and can be applied at any time. |
This is needed to be able to have e.g. 3 PWM slices that are in phase, but may use different duty cycles.
Example usage:
pwm_slices.enable_simultaneous(0b0000_0111);
Demo
Phases between slices before this fix, using
Phases between slices after this fix, using