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-07-30 08:44 AM
I make a cast...
i = (uint8_t) convertedValue;Changing the sample time doesn't change anything...2013-07-31 01:57 AM
Notice I juste use USB power as power source supply. I think the Vref for ADC can be omitted ?
And, once I connect GND or input PIN, my computer lauches the USB On/Off sound..., actually, It seems weird ?If I change, ADC3 to ADC2 (I use Channel 12 on GPIO Port C, so I read on PC2), I don't have funky values but juste the value 0...I can't understand what's the issue.I check ACD_GetConversionValue and returns the same funky values. So, the problem really comes from ADC conversion...Thks.2013-07-31 08:17 AM
The results are going to be highly dependent on the stability of VREF, 1V would be in the 1365 range, beyond the scope of 8-bit. But the swing does look rather excessive for a DC source.
You'll probably need to debug/analyse this yourself.2013-08-01 05:26 AM
Ok...
It seems ADC don't work as well. ADC2 doesn't send anythink and ADC3 ignore entries and send funky values.Do you have an advice or an idea to test the funcioning of these devices (JTAG or SWD) ?Thks.2013-08-02 12:07 AM
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
i = (uint8_t) convertedValue;
Are you looking at a 12 bit result? If so, which 8 of the 12 are you seeing?
2013-08-02 12:28 AM
I tested with an ADC's resolution of 8 bits, so I avoid the cast, and same problems appeared (random values but lower).
2013-08-04 05:38 AM
2013-08-04 08:41 AM
I checked the codes and they seems correct to me. Do you have any idea about this?
I guess I'd ponder how, and at what rate, the data had been offloaded from the system. I didn't spend any time plotting the data, but rather confirmed the sample rate seemed to be correct. DC level seem to have been Ok2013-08-06 05:09 PM
I set a break point at
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);
and expected that the buffer should contain a continuous sampled signal. Since the LED toggles every 2ms, the sampling rate should be correct. I need to figure out how the adc (or dma) fills the buffer.ThanksMS2013-08-06 05:24 PM
Alternating halves of the buffer should have been filled between each interrupt. HT the first half, TC the second half.