cancel
Showing results for 
Search instead for 
Did you mean: 

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

andresfir
Associate II

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);

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

4 REPLIES 4

> 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

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.

 

> 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

Hi, the same for any voltage I choose.