AnsweredAssumed Answered

ADC result alignment

Question asked by Franck80 on May 16, 2014
Latest reply on May 16, 2014 by Franck80
Hello,
I have problem to get the ADC alignment feature working.
config:
STM32F407 on discovery board,
Adjustable voltage (0 to 3V) connected to PA3
ADC resolution set to 12b

Whatever alignment setting I use (ADC_DataAlign_Right or ADC_DataAlign_Lef), the 4 LSb are always 0 and the result range from 0x0000 to 0xFFF0 for 0 to 3V.
The conversion value is right, it just seems that the alignment setting does not have any effect...

Does any one has similar issue?

Here is my code:
uint32_t ConvResult;
 
// Initialize ADC
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);
ADCInitStruct.ADC_Resolution = ADC_Resolution_12b;
ADCInitStruct.ADC_ScanConvMode = DISABLE;
ADCInitStruct.ADC_ContinuousConvMode = DISABLE;
ADCInitStruct.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
ADCInitStruct.ADC_DataAlign = ADC_DataAlign_Right;  // ADC Val max = 4095 @12b resolution
ADCInitStruct.ADC_NbrOfConversion = 1;
ADC_Init(ADC1, &ADCInitStruct);
ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 1, ADC_SampleTime_480Cycles);
ADC_Cmd(ADC1,ENABLE);
 
// ADC Read
ADC_SoftwareStartConv(ADC1);
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) != SET);
ConvResult = ADC_GetConversionValue(ADC1);
printf("%lu: %lx\n", ConvResult, ConvResult);


Outcomes