Skip to main content
AMerc.8
Associate II
April 19, 2023
Solved

STM32H743 Incorrect ADC measurement.

I am having some issues getting meaningful values out of my ADC. At the moment I am capturing ADC samples with the polling mode with the ADC pin being set to approximately 3.2v and 0v. When I check the sample results I am seeing around 20000 for captures taken with the ADC input pin is set to 3.2v and around 14000 when the ADC input pin is set to 0v. Below I have included the current settings for ADC2:

static void MX_ADC2_Init(void)
{
 
 /* USER CODE BEGIN ADC2_Init 0 */
 
 /* USER CODE END ADC2_Init 0 */
 
 ADC_ChannelConfTypeDef sConfig = {0};
 
 /* USER CODE BEGIN ADC2_Init 1 */
 
 /* USER CODE END ADC2_Init 1 */
 
 /** Common config
 */
 hadc2.Instance = ADC2;
 hadc2.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
 hadc2.Init.Resolution = ADC_RESOLUTION_16B;
 hadc2.Init.ScanConvMode = ADC_SCAN_DISABLE;
 hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
 hadc2.Init.LowPowerAutoWait = DISABLE;
 hadc2.Init.ContinuousConvMode = DISABLE;
 hadc2.Init.NbrOfConversion = 1;
 hadc2.Init.DiscontinuousConvMode = DISABLE;
 hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START;
 hadc2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
 hadc2.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;
 hadc2.Init.Overrun = ADC_OVR_DATA_PRESERVED;
 hadc2.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
 hadc2.Init.OversamplingMode = DISABLE;
 if (HAL_ADC_Init(&hadc2) != HAL_OK)
 {
 Error_Handler();
 }
 
 /** Configure Regular Channel
 */
 sConfig.Channel = ADC_CHANNEL_5;
 sConfig.Rank = ADC_REGULAR_RANK_1;
 sConfig.SamplingTime = ADC_SAMPLETIME_387CYCLES_5;
 sConfig.SingleDiff = ADC_SINGLE_ENDED;
 sConfig.OffsetNumber = ADC_OFFSET_NONE;
 sConfig.Offset = 0;
 sConfig.OffsetSignedSaturation = DISABLE;
 if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }
 /* USER CODE BEGIN ADC2_Init 2 */
 
 /* USER CODE END ADC2_Init 2 */
 
}

I am using the TFBGA100 package for this chip so I know there is know VREF pin for the ADC. I have measured the voltage on the VDD pin and it is at 3.2v. I calibrate the ADC before beginning the conversions and there is no less than a 5ms delay between each ADC sample taken. Is there something I'm missing about configuring the reference voltage for this ADC or something else I am missing that could be causing this issue?

This topic has been closed for replies.
AMerc.8
AMerc.8Best answer
Associate II
April 19, 2023

This ended up being a dumb measurement error on my part

1 reply

AMerc.8
AMerc.8AuthorBest answer
Associate II
April 19, 2023

This ended up being a dumb measurement error on my part