Skip to main content
Visitor II
May 6, 2024
Question

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

  • May 6, 2024
  • 2 replies
  • 1071 views

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.

    2 replies

    Super User
    May 6, 2024

    > 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
    Visitor II
    May 6, 2024

    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.

     

    Super User
    May 6, 2024

    > 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
    Visitor II
    May 6, 2024

    Hi, the same for any voltage I choose.