-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
esp32: PWM duty will be changed when changing the frequency if more than one channel is used. #8345
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
Comments
meet same problem by v1.18,work fine by v1.17 |
Fixed since a while. Please use a recent nightly build, and ignore the "unstable" label. The nightly builds are tested the same way than the release build. |
Thank you very much,I just tested the version "esp32-20220226-unstable-v1.18-160-g0a217624e.bin", it can work in 1Hz now, but... the duty will be changed when changing the freq.
|
maybe #8306 is the related issue. I created this issue and closed it soon when I realized that this is fixed in the nightly build. but it seems not really fixed. |
No. It is not. That is something which show up only once after hard reset. I just tested you sequence with my own builds, and it works fine. I just downloaded the nightly build and verify, which esp-idf and version is used. |
I cannot verify your findings. Everything looks as intended. Both the reporting in the print and the actual signal are fine.
|
I test twice,
|
could you reopen this issue? thanks |
You are right. If more than one channel is used, there will be issues with the duty cycle. The basic PR which changed that behavior is #7817. The PR message explains the function and one can see the root of the problem, which is also visible in your log. If a channel's frequency is set to a frequency used by the other channel, it uses this channels timer. That does not take care of potentially different duty cycles. |
sure |
So I made a small change to the code which forces the duty rate to be set on frequency changes. That was omitted when setting to a frequency which was already used in a different channel. The timer for that channel was reused, but still the duty rate had to be adapted. The change is based on a different PR I made earlier, and by chance it fixes #8306 as well. Output from going though the same series as @xky183 above:
|
Fixed by 55a0125 |
Forbidden pins are now correctly "in use" on ESP
After upgrading mpy from 1.17 to 1.18, my buzzer can't play low frequency sounds any more.
With further test, it shows that the pwm has no output when frequencies < 611Hz.
And after switching back to mpy 1.17,
pwm.freq(610)
works fine. I'v tested with another board and I still got the same result. I'm sure this is an issue introduced by v1.18.The text was updated successfully, but these errors were encountered: