Update pwm_stream.c to support ESP32C3 and ESP32C6 (AUD-6603) #1514
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.
Description
The pwm_stream example was not working at all for both the ESP32C3 AND the ESP32C6.
ensuring that these processor variants were included for any processor specific selective code got them working but the ESP32C was 'garbled'.
Investigation found that setting the frame rate to 1/2 of what it actually was in the function pwm_stream_set_clk() would clear this up. This pointed to clock selection issues.
The code uses the define APB_CLK_FREQ for all subsequent timer clock calculations.
for the ESP32C6 this is defined as 40M which causes incorrect timer settings to be calculated when the 80MHZ PLL clock was selected.
Related
Testing
I have tried the same code on an ESP32, ESP32S2, ESP32C3 and ESP32C6 which now all work.
The clock changes for the ESP32C6 will effect a user who has used the ledc_set_timer_div() function, noticed that it actually sets it up wrongly and compensates for it in there own code. Like I nearly chose to fix it by 'tweaking' the frame rate as mentioned above.
Checklist
Before submitting a Pull Request, please ensure the following: