cancel
Showing results for 
Search instead for 
Did you mean: 

L031K6's internal reference voltage is 1.1v?

DU2
Associate II

hello, I am using L031K6 nucleo-32 board.

for using low-power-comparator, I want to use VREF for input.

before using, I did measure the internal reference Voltage by ADC.

L031K6's VREF have internal connection with own ADC VREF channel,

so without hardware setting, I just measure it.

some configuring, then call the  HAL_ADC_GetValue(&hadc).

the return value was '1509', I think it means VREF is equal to 1.1V, because its VDDA is 3V.

is that true? why Is that so low? I expect it will be around 3v.

here is my config code:

************************************************************

 ADC_ChannelConfTypeDef sConfig = {0};

 hadc.Instance = ADC1;

 hadc.Init.OversamplingMode = DISABLE;

 hadc.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV1;

 hadc.Init.Resolution = ADC_RESOLUTION_12B;

 hadc.Init.SamplingTime = ADC_SAMPLETIME_79CYCLES_5;

 hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;

 hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;

 hadc.Init.ContinuousConvMode = DISABLE;

 hadc.Init.DiscontinuousConvMode = ENABLE;

 hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;

 hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START;

 hadc.Init.DMAContinuousRequests = DISABLE;

 hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV;

 hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;

 hadc.Init.LowPowerAutoWait = DISABLE;

 hadc.Init.LowPowerFrequencyMode = DISABLE;

 hadc.Init.LowPowerAutoPowerOff = DISABLE;

 if (HAL_ADC_Init(&hadc) != HAL_OK)

 {

  Error_Handler();

 }

  

 sConfig.Channel = ADC_CHANNEL_VREFINT; //What I really want to see

 sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;

 if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)

 {

  Error_Handler();

 }

    

 if (HAL_ADCEx_Calibration_Start(&hadc , ADC_SINGLE_ENDED) != HAL_OK)

 {

  Error_Handler();

 }

 if (HAL_ADC_Start(&hadc ) != HAL_OK)

 {

  /* Start Conversation Error */

  Error_Handler();

 }

// after that, in main:

__IO uint32_t currentVoltage =0;

currentVoltage = HAL_ADC_GetValue(&hadc);

//and it was 1509

************************************************************

thank you for reading.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

I think you're confusing VREF and VREFINT. VREFINT is an internal voltage reference, it has to be below VDD because that's how voltage references work. VREF is typically the voltage on the VDDA , which is typically the voltage on VDD.

VREFINT is there to allow you to calculate an absolute ADC voltage. You can calculate what VREF is by what value you get from measuring VREFINT.

It wouldn't make sense to take and ADC reading of VREF. It would be the max ADC value every time, plus or minus some noise.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

1 REPLY 1
TDK
Guru

I think you're confusing VREF and VREFINT. VREFINT is an internal voltage reference, it has to be below VDD because that's how voltage references work. VREF is typically the voltage on the VDDA , which is typically the voltage on VDD.

VREFINT is there to allow you to calculate an absolute ADC voltage. You can calculate what VREF is by what value you get from measuring VREFINT.

It wouldn't make sense to take and ADC reading of VREF. It would be the max ADC value every time, plus or minus some noise.

If you feel a post has answered your question, please click "Accept as Solution".