Skip to content

esp32: ADC driver update to the new esp_adc. #16630

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

purewack
Copy link

@purewack purewack commented Jan 23, 2025

Summary

This is a complementary PR to #16521, focusing only on ADC, updating it to fix an issue with the RISCV adc function causing a conflict of drivers mentioned in #16469

There are several errata notes about not being able to change the bit-width of the ADCs certain chips.
The only chip that can switch resolution to a lower one is the normal esp32.
esp32 C2 & S3 are stuck at 12 bits, while S2 is at 13 bits.
On the S2, you can change the resolution, but it has no effect on the resolution, rather, it prevents attenuation from working at all!
I have set the resolution to the be maximum possible for each SoC, with the esp32 being the only one not throwing errors when trying to set the bit-width to 9,10,11 or 12 bits using ADC.width(bits)

Testing

I have built and flashed the following variants: Generic, S2, S3, C3

The ADC behaves correctly as expected, with readings following the position of a 10K potentiometer.
Attenuation works too where values above the maximum range get clipped and readings stay at the maximum attenuated level:

  • ~1v with 0db attenuation
  • ~3.1v using 11db attenuation

@dpgeorge dpgeorge added this to the release-1.26.0 milestone Feb 27, 2025
Copy link
Contributor

@projectgus projectgus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one small note but this looks really nice, thanks for submitting it @purewack!

Signed-off-by: Damian Nowacki (purewack) bobimaster15@gmail.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants