Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with ESP32-S2 #18

Closed
f-peri opened this issue Sep 3, 2022 · 7 comments
Closed

Compatibility with ESP32-S2 #18

f-peri opened this issue Sep 3, 2022 · 7 comments

Comments

@f-peri
Copy link

f-peri commented Sep 3, 2022

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.

@JarekParal
Copy link
Member

@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?

@Tasssadar
Copy link
Member

@JarekParal
Copy link
Member

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

@f-peri
Copy link
Author

f-peri commented Apr 14, 2023

@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:

https://www.espressif.com/sites/default/files/documentation/esp32-s2_technical_reference_manual_en.pdf#ledpwm

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.

@mikaeltulldahl
Copy link
Contributor

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

@mikaeltulldahl
Copy link
Contributor

Seems like @h2zero has solved it here: https://github.com/h2zero/ServoESP32/tree/s3

@mikaeltulldahl
Copy link
Contributor

Should be solved with latest release 1.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants