STM32 F4 – ADC in Dual Mode Simultaneously

adcstm32

I am stuying the example from STM32 libraries (ADC_DualModeRegulSimu). I understand how the whole program works but I need some information and I have few questions about this code confronting to my project.

First of all, I need to convert 2 analog values simultaneously because I plan to compute a phase correlation (that's why I need the simultaneously conversion).
In the code, the converted value are put in a word of length 32 bits :
extern __IO uint16_t aADCDualConvertedValue[2];

I want to stock the first and second value (half-word) in two vector that I have defined. I first decided to create a while statement like this :

while(counter < Max && ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC && ADC_GetFlagStatus(ADC2, ADC_FLAG_EOC)) {
    vector1[counter] = aADCDualConvertedValue[0];
    vector2[counter] = aADCDualConvertedValue[1];
    counter++;
}

But, this method seems to be unsafe because, we can't be certain that aADCDualConvertedValue[0] and aADCDualConvertedValue[1] are sampled at the same time owing to the number of cycles taken by while conditions.
So, what's the best way to stock the simultaneously data safely ?

Another problem, the conversion starts like this (after initializing the two ADC) :
ADC_SoftwareStartConv(ADC1);
ADC_SoftwareStartConv(ADC2);

Does-it mean that ADC2 starts to convert one cycle after ADC1, thus first both samples are not converted simultaneously ?

Thks.

Best Answer

Looking at the hardware of the basic STM unit I'd say there was one ADC and that means no simultaneous sampling. The 16 inputs are likely to be available due to it having an addressable multiplxer which can route one of the 16 to the single ADC input: -

enter image description here

EDIT However, looking at the STM34F4 device it says this (and thanks to Chris Stratton for pointing this out): -

enter image description here

Because the device can do simultaneous sample and hold then this will fit the bill.

Related Topic