cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F373 ADC1 offset

cezis999
Associate
Posted on October 07, 2016 at 11:17

Hello, I have problem with stm32f373 ADC peripheral. My config ADC1 pin PA2 always gives 1.6 V at output, but it's configured as analog input. I usedADC_BasicExample, but result is the same. In errata no information on this problem.

/* ADCCLK = PCLK2/4 */
RCC_ADCCLKConfig(RCC_PCLK2_Div4); 
/* GPIOB Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
/* Configure ADC Channel9 as analog input */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* ADC1 Periph clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
/* ADCs DeInit */ 
ADC_DeInit(ADC1);
/* Initialize ADC structure */
ADC_StructInit(&ADC_InitStructure);
/* Configure the ADC1 in continuous mode */
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
/* Convert the ADC1 Channel 9 with 5 Cycles as sampling time */ 
ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 1, ADC_SampleTime_239Cycles5);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE); 
/* ADC1 reset calibration register */ 
ADC_ResetCalibration(ADC1);
while(ADC_GetResetCalibrationStatus(ADC1));
/* ADC1 calibration start */
ADC_StartCalibration(ADC1);
while(ADC_GetCalibrationStatus(ADC1)); 
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE); 
/* Infinite loop */
while (1)
{
/* Test EOC flag */
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
/* Get ADC1 converted data */
ADC1ConvertedValue =ADC_GetConversionValue(ADC1);
/* Compute the voltage */
ADC1ConvertedVoltage = (ADC1ConvertedValue *3300)/0xFFF;
/* Display converted data on the LCD */
}

2 REPLIES 2
Amel NASRI
ST Employee
Posted on October 12, 2016 at 15:13

Hi vilkas.aurimas,

Did you tried with another ADC channel?

Do you measure the correct voltage on PA2 when disabling ADC clock?

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

cezis999
Associate
Posted on October 18, 2016 at 19:23

Hello Mayla, 

Yes, I have tried with another channel, but still the same voltage offset on all of the channels.

When ADC clock disabled, there is approximately 68-70 mV, so I suspect its correct. 

These channels input impedance is above 1 Mohms, so that is also correct. When I pull down the line with lets say 10 kohm resistor, there is about 50 mV, but for measurement its like another voltage divider so it wont work that way. And besides I never seen anything like that before. 

-vilkas.aurimas-