Closed f-peri closed 10 months ago
@Tasssadar Do you think you can help me with this issue? You have more experience in specific ESP32 modules modification. Is there any define or macro which we can use to check which ESP32 module is used?
Yeah, you can use defines like CONFIG_IDF_TARGET_ESP32S3
: https://github.com/RoboticsBrno/SmartLeds/blob/7e92147351c969b16513b3bf39db2f65b6c8811a/src/SmartLeds.h#L186-L192
There is information that ESP32-S2 has an 18-bits LED PWM controller in their datasheet (page 26): https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf
Then I don't understand why it didn't work with 16-bits.
@f-peri Do you think you can test the code with 18-bits?
ledcSetup(_channel, 50, 18); // channel X, 50 Hz, 18-bits depth
@JarekParal It's been awhile since I've worked on that project, but I'll pull it up and review. I see your point in the ref document: "The accuracy of duty can be up to 18 bits within a 1 ms period." though that wording is a bit vague. The reference I found to 14-bit is:
on page 782: "The LED PWM controller has a 14-bit counter that counts up to 2LEDC_TIMERx_DUTY _RES − 1. If the counting value reaches 2LEDC_TIMERx_DUTY _RES − 1, the counter will overflow and restart counting from 0." Thanks again for investigating.
I got this runtime error while using this library at version 1.0.3 on an ESP32-S3-DevKitC-1
[ 5804][E][esp32-hal-ledc.c:60] ledcSetup(): No more LEDC channels available! (maximum 8) or bit width too big (maximum 14)
E (5571) ledc: ledc_get_duty(739): LEDC is not initialized
Which indicate the same issue and solution as proposed by @f-peri to change from 16 to 14 bits for this chip too
Seems like @h2zero has solved it here: https://github.com/h2zero/ServoESP32/tree/s3
Should be solved with latest release 1.1.0
Hello, thank you for developing this library. I am using the ESP32-S2 and from expressif's documentation, the PWM's are limited to 14-bits. As written, I have not been able to get the code to work on an S2, however, once I changed the ledcSetup call to 14, it works well.
From:
ledcSetup(_channel, 50, 16); // channel X, 50 Hz, 16-bit depth
To:
ledcSetup(_channel, 50, 14); // channel X, 50 Hz, 14-bit depth
You may want to consider with passing this as a variable or creating a function that allows this to be set. Thanks again.