ADC same values in Vref and CH0 (STM32F103C8T6) (CubeIDE)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-06 10:57 AM
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);
//------------------------------------------------------------------------------------------
- Labels:
-
ADC
-
STM32CubeMX
-
STM32F1 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-06 11:42 AM
> 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-06 12:20 PM - edited ‎2024-05-06 12:22 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-06 01:46 PM
> 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-06 01:54 PM
Hi, the same for any voltage I choose.