Skip to main content
SA V.1
Associate III
May 29, 2023
Question

ADC Differential output in STM32H745i DIsco

  • May 29, 2023
  • 3 replies
  • 1175 views

Am configured ADC channel1 as differential mode in STM32H745i disco board .Bellow is my configuration

static void MX_ADC1_Init(void)
{
 
 /* USER CODE BEGIN ADC1_Init 0 */
 
 /* USER CODE END ADC1_Init 0 */
 
 ADC_MultiModeTypeDef multimode = {0};
 ADC_ChannelConfTypeDef sConfig = {0};
 
 /* USER CODE BEGIN ADC1_Init 1 */
 
 /* USER CODE END ADC1_Init 1 */
 
 /** Common config
 */
 hadc1.Instance = ADC1;
 hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV8;
 hadc1.Init.Resolution = ADC_RESOLUTION_16B;
 hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
 hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
 hadc1.Init.LowPowerAutoWait = DISABLE;
 hadc1.Init.ContinuousConvMode = ENABLE;
 hadc1.Init.NbrOfConversion = 1;
 hadc1.Init.DiscontinuousConvMode = DISABLE;
 hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
 hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
 hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR;
 hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
 hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
 hadc1.Init.OversamplingMode = DISABLE;
 if (HAL_ADC_Init(&hadc1) != HAL_OK)
 {
 Error_Handler();
 }
 
 /** Configure the ADC multi-mode
 */
 multimode.Mode = ADC_MODE_INDEPENDENT;
 if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
 {
 Error_Handler();
 }
 
 /** Configure Regular Channel
 */
 sConfig.Channel = ADC_CHANNEL_1;
 sConfig.Rank = ADC_REGULAR_RANK_1;
 sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
 sConfig.SingleDiff = ADC_DIFFERENTIAL_ENDED;
 sConfig.OffsetNumber = ADC_OFFSET_NONE;
 sConfig.Offset = 0;
 sConfig.OffsetSignedSaturation = DISABLE;
 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }
 /* USER CODE BEGIN ADC1_Init 2 */
 
 /* USER CODE END ADC1_Init 2 */
 
}

Am rigup the differential circuit and given AC input 1Vpp ,and DC offset is 1.6V(DC)

in Disco Board ADC1,channel1 as configure differential ADC here Negative input to A2 and positive input to A3 . i am receiving output negatives only and if i flat the graph for that readings noise is present . readings are like this bellow

  ADC_Data:{-5235, -5969, -5201, -5292, -6159, -10756, -6630, -12241, -4321, -9101, -15071, -2818, -16790, -20914, -20897, -16385, -11901, -21713, -20216, -3024, -20810, -15934, -6547, -10002, -8465, -7612, -9142, -6656, -5910, -5231, -5039, -5078, -5145, -5064, -5052, -5133, -5088, -5064, -5037, -5058, -5422, -5040, -5040, -5124, -5378, -5964, -6880, -8817, -7214, -12120, -13670, -14444, -15717, -16831, -6232, -20115, -20883, -21120, -20974, -20255}

Whats wrong i made ? Any help ??

This topic has been closed for replies.

3 replies

AScha.3
Super User
May 29, 2023

if you show the complete input circuit to the adc, it could be possible to help....

"If you feel a post has answered your question, please click ""Accept as Solution""."
SA V.1
SA V.1Author
Associate III
May 29, 2023


_legacyfs_online_stmicro_images_0693W00000bl2KoQAI.png

AScha.3
Super User
May 29, 2023

ok, ...from LT data; you build exactly so?

  1. adc data is uint32 , cannot be negative ! (you have wrong size, probably int )
  2. did you run "...calibrate() " ? (-> differential here)
  3. first check without AC signal: DC voltage at +/- IN pins
  4. check without AC signal: ADC values ...
  5. at first set no oversampling and no bit shifts, just to see the conversion result
"If you feel a post has answered your question, please click ""Accept as Solution""."