https://toitlang.org/ logo
ESP32-S3 PWM error
# help
i
When initialising the PWM generator
generator := pwm.Pwm --frequency=400
I receive this error:
Copy code
E (218246) ledc: freq_hz=400 duty_resolution=17

******************************************************************************
Decoding by `jag`, device has version <2.0.0-alpha.134>
******************************************************************************
EXCEPTION error.
UNKNOWN ERROR 0x102(258)
  0: pwm-init_                 <sdk>\gpio\pwm.toit:177:3
  1: Pwm                       <sdk>\gpio\pwm.toit:103:12
  2: RGBLED                    espnow\rgb-led.toit:10:16
  3: main                      test\02-rgb-led.toit:4:10
******************************************************************************
From this page: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/error-codes.html Error 0x102 means:
ESP_ERR_INVALID_ARG (0x102): Invalid argument
just found another thread with no solution: https://discord.com/channels/918498540232253480/1186697368595333150/1186697368595333150 It might has to do with a change in the IDF again?
f
I'm guessing we are computing the duty-resolution incorrectly. Maybe we always did, maybe they changed it with an IDF change. Will try to look at it later today. (Firefighting a few things right now)
i
it works for me so far with the 10k frequency so its fine for now
f
The ESP32 accepts
--frequency=400
. Could be that the ESP32S3 works differently and we don't make that distinction in the code...
Confirmed: the ESP32 works, but the ESP32S3 doesn't. I'm looking at the docs now to figure out how they differ.
I'm pretty sure the ESP32S3 doesn't support 400Hz.
i
From this thread:https://esp32.com/viewtopic.php?t=24717#:~:text=The%20maximum%20PWM%20frequency%20is,the%20period%20is%206.25%20ns. 140MHz is max for the ESP32S3
f
But we are looking at the min here
i
generator := pwm.Pwm --frequency=2050
seems to be the lowest, was not trying any further then that but less will cause the error to happen
f
It might be possible to change the clock that drives the PWM, but from what I can see that would only give a factor of 4.
i
not very important tbh - I just want to blink an LED and stumbled over this problem