cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to connect 2 Internally connected PGAs to ADC2 in STM32G series?

just4u78
Associate II

My goal is to connect 2 internal PGAs to 1 ADC (especially ADC2).

 

I configured in CubeMX and generated source code.

ADC_Assign_Test.png

 

However, when I checked the ADC channel initialization code in IDE project, I could see that only one channel is activated in ADC2.

 

 

/**

* @brief ADC2 Initialization Function

* @param None

* @retval None

*/

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

hadc2.Init.Resolution = ADC_RESOLUTION_12B;

hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;

hadc2.Init.GainCompensation = 0;

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.DMAContinuousRequests = DISABLE;

hadc2.Init.Overrun = ADC_OVR_DATA_PRESERVED;

hadc2.Init.OversamplingMode = DISABLE;

if (HAL_ADC_Init(&hadc2) != HAL_OK)

{

Error_Handler();

}

 

/** Configure Regular Channel

*/

sConfig.Channel = ADC_CHANNEL_VOPAMP2;

sConfig.Rank = ADC_REGULAR_RANK_1;

sConfig.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;

sConfig.SingleDiff = ADC_SINGLE_ENDED;

sConfig.OffsetNumber = ADC_OFFSET_NONE;

sConfig.Offset = 0;

if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN ADC2_Init 2 */

 

/* USER CODE END ADC2_Init 2 */

 

}

 

 

 

I've tried it on several G-series MCUs, but they all show the same symptoms.

 

What is the problem?

0 REPLIES 0