-
Notifications
You must be signed in to change notification settings - Fork 234
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
PWM is not atomic/sync with WFI and cleared clk_sys_pwm
#561
Comments
I guess this is just the way the hardware works: If you disable |
Yes this is the case, but the API provides a disable() which is the same like duty(0) and it doesn't provide something to disable PWM before sleep without invalidating the settings, because it is owned memory. Per register you could disable PWM but in Rust this stuff is already owned, so you can not modify. |
|
@kolbma Disabling the PWM does not mean setting the pin to 0. Say you are disabling the the PWM in the middle of a high-phase, if the PIN were brought down immediately, it would be creating low dutycycle glitches. What you need is a way to wait for the end of the current cycle once you set the duty to 0. |
Interesting observation. Is there any use case where reading |
|
Thanks for reactions of all of you. Well, could not try, I think there is no chance to disable the slice, while there are channel assignments:
Or without using refs:
Would work only if I drop all this before What happens to PWM, if I disable the used pin? Compiling is possible: Maybe this is the way to go, and let the PWM part do whatever it likes to do without a clock and without output pin. But not sure if you should name it disable when there is nothing disabled ;-) Also when it is not possible to disable a setup and used slice, how do you want to sync the slices (called channels in datasheet) like it is described in PWM: EN Register...?
The |
It continues running, unaware that the pin is no longer following it's commands.
Indeed, TBH
Indeed
I think disabling the pin in a given state is your way to go then :) |
I fully agree! Unfortunately, we don't really have a choice here: Note that this is inside rust-embedded/embedded-hal#430
It might not fit well to your code layout, but it may be possible to avoid destructuring.
you could do this:
|
Oh, yeah ;-) I oversaw that. There is no need to have the channel-struct all the time available, once registers are set. Thank you very much. |
When sleeping with disabled
clk_sys_pwm
there is some undefined result for PWM-channels.I
set_duty(0)
ordisable()
the channel before going to sleep, but sometimes the LEDs stay on the oldduty
, rare it is lighting with full power instead going off.If I do about 2000 or more
asm::nop()
beforewfi()
the chance of occurrence is lower, but not gone.With
clk_sys_pwm
-bit set, there is no problem.When I interpret the datasheet correctly, there should be no problem with disabling pwm during sleep and reusing it afterwards.
The text was updated successfully, but these errors were encountered: