-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
drivers: pwm_led: esp32: Driver update #82820
Conversation
Thanks for this, I think it can supersede my PR #82177? I'll merge and test. There's an open comment on my PR that still worth consideration here: I proposed either supporting only one clock source or, moving the clock source to the device tree. The rationale: All low speed channels share the same clock source. On a device such as esp32 that has multiple clock choices: suppose there are two distinct PWM low-speed channels each using a distinct timer. Then call Thoughts? Initialize an immutable clock source in driver init, rather than reconfiguration on-the-fly? In any-case thanks for PR: LGTM. My issue's not a new bug and exists before and after this PR. |
I tested on esp32c3 working-as-intended but, one suggestion: Do you think it makes sense to reinitialize/reset the timer only when the clock selection changes, rather than every time the frequency changes? As-is here's what it looks like when I change the freq: If the timer had not been reset, the trigger point would be updated on the next overflow resulting in a smooth transition to the new frequency. |
hi @braiden |
5f53d2d
to
0951187
Compare
0951187
to
443831e
Compare
ec8fba7
to
033d38c
Compare
033d38c
to
6c3de71
Compare
I attempted the testcase you mention above and here's what I get:
Signals are fine on the oscilloscope. The condition you mention makes sense when the same timer is used instead, and for this situation a check is now made on |
Hi @raffarost First I had some trouble with the led_shell and setting led brightness.
I got the same errors when trying to set a 100Hz frequency with the pwm_shell: Increasing it to 1000Hz fixed it though. Is there a reason why low frequencies are not supported? |
hello @epc-ake |
Yes I'm using the esp32s3. |
6c3de71
to
8b89060
Compare
I included the fix that is already in place in the driver, so now it reaches 10 Hz on S3 and preserves the original functionality. |
confirmed 👍 |
d7a704c
8b89060
to
d7a704c
Compare
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.
just a nits, LTGM
4385110
d7a704c
to
4385110
Compare
This PR enables the PWM to be inverted by making use of the `PWM_POLARITY_INVERTED` flag. It also fixes an overflow bug when setting duty-cycle to 100 percent. Signed-off-by: Armin Kessler <ake@espros.com>
Set pwm init state to value defined in flags field. Furthermore 100 percent is now actually 100 percent and not 99. Signed-off-by: Armin Kessler <ake@espros.com>
At driver init channels frequency are unknown, thus timer config may take place only at set_cycles(). To avoid phase shifts, timers are only reconfigured if a new frequency is requested. Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Disable PWM output for duty 0% or 100%, to allow using max timers resolution. Move timer reset to init function in order to ensure smooth frequency transitions. Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Cleanup and functions organization. Clock source selection added to init to allow proper setting of default level when signal is inverted. Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Include condition to block pwm_set operation when the same timer is shared but a different frequency is requested. First set operation will take precedence. Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Update clock management to better support new devices. Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Clang check for formatting. Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Add inverted flag to bindings, as pwms field is supposed to be used by application only. Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Add test cases to include coverage for ESP32 HS channels. Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Hi @kartben |
Update LEDC driver in order to address GH reported issues and improve clock management.
Following behaviors are ensured:
Note: changes were kept in several commits to facilitate review, but can be squashed if requested.