2013-07-22 06:27 AM
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
2013-08-07 08:38 AM
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.2013-08-08 06:49 AM
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.2013-08-08 08:01 AM
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.2015-04-08 03:46 AM
Hey Clive,
You are usingDMA_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;