ESP32S3 ADC sampling using DMA

paradigmshift
Posts: 1
Joined: Tue Aug 13, 2024 5:44 am

ESP32S3 ADC sampling using DMA

Postby paradigmshift » Tue Aug 13, 2024 10:58 am

Dear All,

I have been trying to design a C++ class for wrapping ADC sampling with DMA based on a circular buffer.
I was not able to make the DMA work although i was able to compile and write the ADC continuous mode config code.
What i want to accomplish is the following:

- I am hopping for a CPU free of load for ADC sampling if possible.
- I was thinking a circular buffer of 100-1000 bytes somewhere in that range.
- A pointer to the element that was just fed with the last ADC sample.
- The ADC sampling must constantly be populating the buffer in a circular manner.

I am using ESP IDF 5.1.1 with PlatformIO in VSCode.

So far i was only able to work with the oneshot mode.

Are all the above doable? (circular buffer and such)

Any example would be gold.

Thanks in advance.

Regards
Manos

djixon
Posts: 113
Joined: Sun Oct 01, 2023 7:48 pm

Re: ESP32S3 ADC sampling using DMA

Postby djixon » Sat Aug 17, 2024 8:47 am

You can use ULP co-processor integrated into S3 to do that for you with 0% utilization of both LX7 cores. It also can work in deep sleep mode where both LX7 cores are shut down. There are examples within IDF how to do that. Basically, the only you need is a few bytes in fast ram to store measured values (that ram is shared among ULP and LX cores) and several hundred of bytes in that ram for ULP program which will actually perform ADC. Usual scenario of such a setup is like this. Once chip is powered on, ULP program (usually written in assembly and compiled for ULP coprocessor) is uploaded into fast memory and ULP is configured and started to run it. It can be written in infinite loop so it works forever as long as chip is not reset or powered down.

Who is online

Users browsing this forum: No registered users and 251 guests