Circular DMA reading ADC

felixcollins
Posts: 123
Joined: Fri May 24, 2019 2:02 am

Circular DMA reading ADC

Postby felixcollins » Wed Jun 29, 2022 10:39 pm

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!

username
Posts: 477
Joined: Thu May 03, 2018 1:18 pm

Re: Circular DMA reading ADC

Postby username » Sun Jul 24, 2022 3:22 pm

I too would like to know. Anyone ?

felixcollins
Posts: 123
Joined: Fri May 24, 2019 2:02 am

Re: Circular DMA reading ADC

Postby felixcollins » Tue Feb 14, 2023 12:08 am

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.

felixcollins
Posts: 123
Joined: Fri May 24, 2019 2:02 am

Re: Circular DMA reading ADC

Postby felixcollins » Wed Mar 01, 2023 11:55 pm


Who is online

Users browsing this forum: No registered users and 129 guests