Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3436

General • Mutli-channel, multi-sample DMA ADC reads

$
0
0
I've been going through the post here viewtopic.php?hilit=dma%20adc&p=2101823 ... bc131bd3c2 but finding it very hard to follow. I want to adapt it so that I continuously read 2 ADC inputs at a fixed sample rate but fill a buffer with a fixed number of samples from each ADC channel so I can perform an FFT. That example just reads the ADCs once before printing the output and then relies on a delay to set the sample rate.

I've set the specific ADCs I want to use and set the sample rate via the clock divider and then changed the count_of() field in the dma_channel_configure() so it becomes...

Code:

  dma_channel_configure(        samp_chan,         &samp_conf,        nullptr,        &adc_hw->fifo,        num_channels * num_samples,        false    );
but I don't know how to access the ADC data. The destination is nullptr in the above code because it is set by the control DMA channel, which is...

Code:

&dma_hw->ch[samp_chan].al2_write_addr_trig
In the simple, single channel examples I've seen, this is an array that can be indexed for the data but I can't figure out how to extract data from this. Trying to print it out causes a freeze.
I'm using the Arduino IDE so my code structure is different from the original but can still post if needed.

Statistics: Posted by StarryPied — Mon Jan 29, 2024 10:40 am — Replies 0 — Views 14



Viewing all articles
Browse latest Browse all 3436

Trending Articles