Why is 1.24 ESP32-s3 PWM wrong? October 26 git #16086
-
version to 1.24.0 When I roll back version to 1.23.0 I'm using the ESP32_GENERIC_S3 build, esp-idf-V5.2.2 I tried to build using the file downloaded on September 30, PWM is no problem -- MicroPython v1.24.0-preview.363.g17d823445 |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 16 replies
-
When you try it on the previous version, do you have any way to measure the actual frequency generated on the pin? Eg an oscilloscope? I ask because there was a bug found in the previous versions where the clock sources used to run the pwm were declared incorrectly, I expect the frequency was not actually calculated correctly in the older version. I'm not sure if that's what's going on here but it might be related. |
Beta Was this translation helpful? Give feedback.
-
It is this commit which breaks it:
|
Beta Was this translation helpful? Give feedback.
-
This is a BUG and has to be fixed. The actual firmware works for ESP32 and indeed ESP32C6, but fails on ESP32S3. I did not yet test the other ESP32 variants. |
Beta Was this translation helpful? Give feedback.
-
Is this on the S3? Which board profile? Repl was enabled on USB there last I checked, my main S3 board doesn't have UART wired at all. There has been a couple of changes more recently enough to make it easier to build without USB enabled to free up the pins, maybe the defaults for accidentally changed then. |
Beta Was this translation helpful? Give feedback.
-
Ok, so that error message is given for any error returned by micropython/ports/esp32/machine_pwm.c Line 256 in 6d79937 I'm not sure why the new settings are wrong here for S3, though there are multiple issues in this pwm configuration code, eg. #15862 (comment) I'm in the middle of USB work for other ports, not sure when I'll have time to look at esp32 next. Perhaps there's some newer reference code elsewhere for setting up pwm on all the esp32 chips we could use as a guide for doing this better. |
Beta Was this translation helpful? Give feedback.
-
I've got a fix for the issue raised in #16090 based on previous suggestions by @projectgus @robert-hh This test was using repl over usb cdc (using the full / tinyusb based usb stack) which is default on ESP32_GENERIC_S3. Or were you referring to the alternate USJ cdc stack in the chip which can alternatively be enabled instead? I haven't tried using that on the S3. |
Beta Was this translation helpful? Give feedback.
It is this commit which breaks it:
6d79937
2024-10-09 esp32: Add support for esp32c6.
And especially these lines, causing the frequency to be limited to a range of 4 - 2000 Hz.
SOC_LEDC_SUPPORT_XTAL_CLOCK
is defined for all chips except ESP32.That difference is strange since the S3 board I have uses a 40MHz Crystal, which is of course different to the 80Mhz APB clock. But still 5 kHz should be possible.