cancel
Showing results for 
Search instead for 
Did you mean: 

ADC in Dual Mode Simultaneously

paul-henri
Associate II
Posted on July 22, 2013 at 15:27

Hi everyones,

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.

#adc #stm32
23 REPLIES 23
paul-henri
Associate II
Posted on August 07, 2013 at 17:38

Hi,

I changed my board (random values disapear), and the example provided by cliv1 is working but juste for one input... Indeed, I juste have the Half Transfer (for example I juste have ADCConvertedValues[0], ADCConvertedValues[2]...). For the Transfer Complete(ADCConvertedValues[1], ADCConvertedValues[3]...) I have zero values.

I switched pins and I really have the second sensor but now put in the Half Transfer.

I don't understand why the Transfer Complete values aren't fill...

Thks.

paul-henri
Associate II
Posted on August 08, 2013 at 15:49

In fact, now your code is well working. It would have been a problem with pins configuration...

Last question, I hope, about the frequency. I use a SysTick_Handler to measure time takes for each conversion of all values (BUFFERSIZE).

For example, I have a buffersize of 200 and a TIM frequency of 1000. So, the step time should be 100 ms but my delay counter measures 25 ms... This is fourth lower...

Maybe, it should be errors on frequencies (APB1 frequency ?). I check my system clock, and it is well put at 168 Mhz.

Thks.

Posted on August 08, 2013 at 17:01

I don't know if that amounts to errors.

The teeth on the clock's gears are all defined/programmed, the ratios are what they are. You'll need to look very carefully at all the settings, and export clocks via TIM or MCO pins to confirm them if you need to. Start with system_stm32f4xx.c and dig back from there.

The interrelationship of the clocks is diagrammed in the Clock Tree for the part.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
cyqdtc
Associate II
Posted on April 08, 2015 at 12:46

Hey Clive,

You are using

DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;

Since the FIFO is half full, meaning it has 2*32 bits. Should not it be the following?

DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_INC4;