2016-10-07 02:17 AM
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 */
}
2016-10-12 06:13 AM
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.
2016-10-18 10:23 AM