Skip to main content
Associate
May 6, 2024 5:57 PM UTC
Question

ADC same values in Vref and CH0 (STM32F103C8T6) (CubeIDE)

Hello everyone! I can't figure out what my mistake is, from the next code, I have the same values for CH0 and VREF (I read others' replies but they don't work for me).

What I'm doing wrong?

//------------------------------------------------------------------------------------------

sConfigPrivate.Channel = ADC_CHANNEL_0;

HAL_ADC_ConfigChannel(&hadc1, &sConfigPrivate);

HAL_ADC_Start(&hadc1);

HAL_ADC_PollForConversion(&hadc1,100);

x = HAL_ADC_GetValue(&hadc1);

HAL_ADC_Stop(&hadc1);

V = x* 1.25 / vref;

 

sConfigPrivate.Channel = ADC_CHANNEL_VREFINT;

HAL_ADC_ConfigChannel(&hadc1, &sConfigPrivate);

HAL_ADC_Start(&hadc1);

HAL_ADC_PollForConversion(&hadc1,100);

vref = HAL_ADC_GetValue(&hadc1);

HAL_ADC_Stop(&hadc1);

//------------------------------------------------------------------------------------------

This topic has been closed for replies.

4 replies

waclawek.jan
Super User
May 6, 2024 6:42 PM UTC

> I have the same values for CH0 and VREF

And that is?

Read out and check/post content of ADC registers just after the first and second conversion.

JW

andresfirAuthor
Associate
May 6, 2024 7:20 PM UTC

Hi, If I connect CH0 to ground the result is 0 for both. I´m reading and doing multiple tests, but they don't work.

 

waclawek.jan
Super User
May 6, 2024 8:46 PM UTC

> If I connect CH0 to ground the result is 0 for both.

And if you don't connect CH0 to ground?

Read out and check/post content of ADC registers just after the first and second conversion.

JW

andresfirAuthor
Associate
May 6, 2024 8:54 PM UTC

Hi, the same for any voltage I choose.