Page 1 of 1

Circular DMA reading ADC

Posted: Wed Jun 29, 2022 10:39 pm
by felixcollins
I have a system where I am reading the ADC (via DMA using I2S driver) and copying the data to a circular buffer until I receive an external interrupt.

Once the interrupt is received, I wait for a time, then stop the ADC/DMA. I then process a section of the circular buffer from before and after the interrupt point.

I 'd like to avoid the copy overhead from the DMA buffers to the big circular buffer.

It seems like this should be feasible using a circular linked list of DMA buffers, but there is no support for this in the driver and getting it to work by experimentation with the DMA registers could be very time consuming.

Does anyone have a relevant example of similar code? Could someone familiar with the hardware and the I2S driver give me some tips as to what is required to make this work?
In particular:

1.How should I modify the DMA setup?
2.How to stop the ADC/DMA?
3.How can I read the location it had got to in the buffers when stopped?
4.Can I use a single large DMA buffer in a circular mode?

Thanks very much in advance!

Re: Circular DMA reading ADC

Posted: Sun Jul 24, 2022 3:22 pm
by username
I too would like to know. Anyone ?

Re: Circular DMA reading ADC

Posted: Tue Feb 14, 2023 12:08 am
by felixcollins
I'm still waiting to find more information on this. The continuous mode adc driver comes so close. https://docs.espressif.com/projects/esp ... nuous.html

Unfortunately it fills up and stops if you do not read it repeatedly thereby incurring a copy overhead for every single sample.

Can an ESP IDF dev please advise on how easy it would be to modify the adc_continuous driver to allow a rolling circular DMA buffer? The mode of operation I envisage is:

1. Set it going on a large circular buffer. The DMA simply overwrites the oldest samples rather than getting a pool overflow event.

2. Halt the ADC and read the DMA to get the location in the buffer of the most recent sample

3. Read directly from the DMA buffer whatever portion of the samples is desired.

Re: Circular DMA reading ADC

Posted: Wed Mar 01, 2023 11:55 pm
by felixcollins