cancel
Showing results for 
Search instead for 
Did you mean: 

ON STM32L476 ADC in Dual regular simultaneous mode only does not work properly. HAL_ADC_ConvHalfCpltCallback() occurs only once after calling: HAL_ADC_Start(&hadc2): HAL_ADCEx_MultiModeStart_DMA(&hadc1, ADC1_count, ADC1_BUFF_LEN);

FFran.6
Associate

ON STM32L476 ADC in Dual regular simultaneous mode only does not work properly. HAL_ADC_ConvHalfCpltCallback() occurs only once after calling: HAL_ADC_Start(&hadc2)

HAL_ADCEx_MultiModeStart_DMA(&hadc1, ADC1_count, ADC1_BUFF_LEN).

After calling:

HAL_ADCEx_MultiModeStop_DMA(&hadc1)

HAL_ADC_Stop_DMA(&hadc2)

I cannot restart conversion by calling ADC start as shown below

HAL_ADC_Start(&hadc2):

HAL_ADCEx_MultiModeStart_DMA(&hadc1, ADC1_count, ADC1_BUFF_LEN).

The conversion complete callback HAL_ADC_ConvHalfCpltCallback() is never called again if ADC stopped using calls described above.

this is configuration for ADC 1

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

 hadc1.Init.Resolution = ADC_RESOLUTION_12B;

 hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;

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

 hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;

 hadc1.Init.OversamplingMode = ENABLE;

 hadc1.Init.Oversampling.Ratio = ADC_OVERSAMPLING_RATIO_2;

 hadc1.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_1;

 hadc1.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER;

 hadc1.Init.Oversampling.OversamplingStopReset = ADC_REGOVERSAMPLING_CONTINUED_MODE;

 if (HAL_ADC_Init(&hadc1) != HAL_OK)

 {

  Error_Handler();

 }

 /** Configure the ADC multi-mode

 */

 multimode.Mode = ADC_DUALMODE_REGSIMULT;

 multimode.DMAAccessMode = ADC_DMAACCESSMODE_12_10_BITS;

 multimode.TwoSamplingDelay = ADC_TWOSAMPLINGDELAY_1CYCLE;

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

 sConfig.SingleDiff = ADC_SINGLE_ENDED;

 sConfig.OffsetNumber = ADC_OFFSET_NONE;

 sConfig.Offset = 0;

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

 {

  Error_Handler();

 }

 /* USER CODE BEGIN ADC1_Init 2 */

 /* USER CODE END ADC1_Init 2 */

}

/**

 * @brief ADC2 Initialization Function

 * @param None

 * @retval None

 */

Below is the configuration for ADC2

 /* 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_12B;

 hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;

 hadc2.Init.ScanConvMode = ADC_SCAN_DISABLE;

 hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV;

 hadc2.Init.LowPowerAutoWait = DISABLE;

 hadc2.Init.ContinuousConvMode = ENABLE;

 hadc2.Init.NbrOfConversion = 1;

 hadc2.Init.DiscontinuousConvMode = DISABLE;

 hadc2.Init.DMAContinuousRequests = DISABLE;

 hadc2.Init.Overrun = ADC_OVR_DATA_PRESERVED;

 hadc2.Init.OversamplingMode = ENABLE;

 hadc2.Init.Oversampling.Ratio = ADC_OVERSAMPLING_RATIO_2;

 hadc2.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_1;

 hadc2.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER;

 hadc2.Init.Oversampling.OversamplingStopReset = ADC_REGOVERSAMPLING_CONTINUED_MODE;

 if (HAL_ADC_Init(&hadc2) != HAL_OK)

 {

  Error_Handler();

 }

 /** Configure Regular Channel

 */

 sConfig.Channel = ADC_CHANNEL_2;

 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();

 }

Can anyone help me with this problem?

Thank you,

0 REPLIES 0