ESP32 DevkitC PWM_Fade example doesn't work as supplied


#1

The example, as written does not produce a PWM signal in microseconds. I get a waveform with high time of 6.52 seconds, and low time of .6 seconds as seen below. However, the example works fine if you use MILLIS for the time units. The ESP32 can certainly handle microsecond PWMs via its LEDC controller, as one example.


#2

Hello bmiller,

for esp32 devices the max PWM freq is ~2kHz (period max 500 uS).
If you put your code inside a try-except block you should obtain a message like this:

E (11463) ledc: requested frequency and duty resolution can not be achieved, try reducing freq_hz or duty_resolution. div_param=62
Thread 1 exited with exception InvalidHardwareStatusError @[0019:001D:0000:0053:0000:0000:0000:0000]

Let me know if you have any other doubts


#3

Thanks. As a newcomer to Zerynth, I would have expected the examples to work on a supported board. Might be a good idea to preface each demo program with a line stating which MCU/boards have been tested.
From other experience with ESP32, I know that LEDC can support much higher PWM freqs than 2 kHz- particularly if you use resolutions less than 16 bits, so this must be a limitation in Z’s library.