cancel
Showing results for 
Search instead for 
Did you mean: 

STM32l052 Vrefint 2048 problem

baev_al
Associate II
Posted on September 18, 2015 at 08:52

Hi.

I try to measure internal voltage and temperature. The first measurement of the both is good. In all the others voltage is 2048, while temperature is ok.

The controller uses MSI 2000000MHz.

The measurement occurs once in a minute (interrupt from RTC).

Here is the ADC initialization.

void MX_ADC_Init(void)

{

  ADC_ChannelConfTypeDef sConfig;

 

  hadc.Instance = ADC1;

  hadc.Init.OversamplingMode = DISABLE;

  hadc.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2;

  hadc.Init.Resolution = ADC_RESOLUTION12b;

  hadc.Init.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;

  hadc.Init.ScanDirection = ADC_SCAN_DIRECTION_UPWARD;

  hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;

  hadc.Init.ContinuousConvMode = DISABLE;

  hadc.Init.DiscontinuousConvMode = DISABLE;

  hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIG_EDGE_NONE;

  hadc.Init.DMAContinuousRequests = DISABLE;

  hadc.Init.EOCSelection = EOC_SINGLE_CONV;

  hadc.Init.Overrun = OVR_DATA_OVERWRITTEN;

  hadc.Init.LowPowerAutoWait = DISABLE;

  hadc.Init.LowPowerFrequencyMode = DISABLE;

  hadc.Init.LowPowerAutoOff = DISABLE;

  HAL_ADC_Init(&hadc);

  sConfig.Channel = ADC_CHANNEL_TEMPSENSOR | ADC_CHANNEL_VREFINT;

  HAL_ADC_ConfigChannel(&hadc, &sConfig);

}

Here is the measurement part:

  ADC1->CR |= ADC_CR_ADSTART;

  while ((ADC1->ISR & ADC_ISR_EOC) == 0); /* Wait end of conversion */

  V_measured = hadc.Instance->DR;

  while ((ADC1->ISR & ADC_ISR_EOC) == 0);

  T_measured = hadc.Instance->DR;

The calibration is present and ok.

Why the value of Vrefint always measures as 2048?
0 REPLIES 0