cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F3 simultaneous ADC conversions

Jakub Konieczny
Associate II
Posted on May 09, 2018 at 12:54

Hi.

I want to do do ADC conversions on all 3 ADCs simultaneous: they should be done in the same time. How should I achieve that?

1. With DMA? I can do multichannel conversions, but they are not simultaneous. When I start `HAL_ADC_Start_DMA(&hadc1, adcData[0], 5);` 3 times, it looks like it does conversions for each ADC synchronous. MultiMode is only for 2 DMA channels and I need to do 3 measurements simultaneous.

2. With IRQ: start conversions with interrupts and catch them all, and then when I get all 3 start them again?

3. Mix them?

#stm32f3 #dma #adc
8 REPLIES 8
S.Ma
Principal
Posted on May 09, 2018 at 14:14

Normally the result of an ADC conversion is pushed onto a register. This value is available until the ADC took the time to finish converting the next conversion and overwrite the register.

To synchronize all 3 ADC only require to share the same start of conversion. Reading the 3 registers don't have to be done at the same CPU cycle speed. Thoughts?

Posted on May 09, 2018 at 14:16

Seem to think you can have ADC1&2 and ADC3&4 share a common TIM trigger, thus effecting paced and simultaneous acquisitions.

Likely will need to use two DMA, so two separate arrays. I know I built a 4-UP ADC with the F3+SPL

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 09, 2018 at 14:57

I have only one free DMA for this.

This CPU has 3 SDADC (forgot to mention it's Sigma Delta, if that matters). So just start all 3 with interrupts in continous mode and read results in interrupt handler? Is it ensured that the measurements will not dissynchronize? I mean if I start 3 SDADCs in the same time (+- few CPU cycles, doesn't matter), time difference between each next measurements will be constant? After 5 seconds, every SDADC will do same amount of measurements?

Posted on May 09, 2018 at 19:05

Check out the core speed SYSCLK in MHz and each ADC Sampling frequency. Are all ADC sharing the same sampling frequency?

Posted on May 10, 2018 at 08:02

Everything is configured in the same way. Every ADC is the same.

Posted on May 10, 2018 at 15:42

Take your ADC sampling frequency and find out how many core cycles this correspond to.

It will tell you if an interrupt of high priority can read all ADC registers and back it up before the next one.

Posted on May 10, 2018 at 15:43

Note: Actually this is only a quick look at the clock prescalers, no need the absolute value.

kader ben
Associate
Posted on May 13, 2018 at 21:46

hello please, I have a robotics project where I'm forced to use a stm32f3, but I do not know about stm32, I need a basic code to perform the digital analog conversion a continuous signal through pin PA0 ( first adc_in), to understand this part. thank you in advance.