cancel
Showing results for 
Search instead for 
Did you mean: 

High-speed data acquisition using ADC on stm32f3 for real-time signal processing.

S12344
Associate II

My application is to implement a real-time signal processing algorithm on the STM32F3 microcontroller. I'm not using FreeRTOS.

Details on what I want to do:

  1. I'm planning to use ADC in dual interleaved mode, which would result in a sampling rate of around 10 MSPS.
  2. Using the DMAConvCpltCallback and DMAConvHalfCpltCallback -> So that I can process the first buffer while the second buffer is being filled by ADC,
  3. The processing of data includes simple averaging, comparing the data to threshold value and fft.

My doubt is: Whether it will be possible to do the processing before the first DMA gets overwritten? How can I verify the timing requirements for processing to make sure it doesn't get overwritten? Because as per the tutorials/forums I've seen by now, FFT consumes a lot of time. Should I do this application into FreeRTOS?

9 REPLIES 9
TDK
Guru

Toggle a pin within the interrupt to see long long it takes. Or check for half- and full transfer complete flags at the exit to ensure they haven't yet happened.

It probably won't be possible to continuously process 10 Msps in a nontrivial way. Doing it in FreeRTOS would be even worse than as bare metal as it will add additional overhead. Using HAL is going to slow it down even more.

If you feel a post has answered your question, please click "Accept as Solution".
S12344
Associate II

I thought of storing more samples in a buffer. But still, FFT will not be fast enough to compensate.

Suppose, I check the flags for Transfer complete, and it says '1'. For sure, the FFT operation would not be completed by that time for the first buffer. Can I store the data of the second buffer on another address and continue doing FFT?

Storing data in another place isn't going to help if you can't keep up. DMA can be used in double buffer mode, but it won't help here. At some point you will need to stop data collection and finish FFT processing, or lose data.
If you feel a post has answered your question, please click "Accept as Solution".

So, the best option for me is to stop ADC after the second buffer gets filled. Process everything and then start ADC again.

So, the best option for me is to stop ADC after the second buffer gets filled. Process everything and then start ADC again.

MM..1
Chief II

When you plan real time then need balanced sampling speed vs calculted values. No stop ADC...

Circular DMA is perfect for offload ADC from MCU.

For skip some ADC is better use only switch DMA to dummy and valid buffers.

Can you explain the last line?

Primary you config DMA for example to receive 1024 samples , then on first 512 ocur half IRQ and you start calculate first half samples.

On second IRQ is next 512 samples ready and if calculation isnt complete in this IRQ you change DMA to second dummy buffer address.

For best speed use direct registers change without HAL...

After calculation is complete you set flag and in same IRQ switch back to primary buffer.

Calculation you can do on both or only on primary buffer, but start only in half complete IRQ...

Patukes
Associate III

@S12344

Please were you able to implement the dual interleave adc mode?if yes please can you share it with me. Thank you