cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple ADC channels on STM32L072xx

CDesh
Associate III

I am using STM32L072xx module and I would like to use ADC4, ADC5 and ADC 17 (Vrefint) at the same time. But I want to use ADC4 with DMA of buffer size 500 or more. It is not necessary to store ADC5 & ADC17 in DMA.

Can I use DMA only for ADC 4 and dump 500 samples and use the following API calls for ADC5 and ADC17?

  HAL_ADC_Start( &hadc);

  /* Wait for the end of conversion */

  HAL_ADC_PollForConversion( &hadc, HAL_MAX_DELAY );

  /* Get the converted value of regular channel */

  adcData = HAL_ADC_GetValue ( &hadc);

Is this the right way of configuring multiple ADC channels?

11 REPLIES 11
CDesh
Associate III

@Philippe Cherbonnel​ Thanks for your constant support.

I am able to resolve the conflict by calling the following function. I referred to an example from

STM32Cube_FW_L0_V1.12.0\Projects\NUCLEO-L073RZ\Examples\ADC\ADC_DMA_Transfer which helped me fix the issue on ADC DMA with comparator. #ADC​  #DMA​ #COMP​ 

/**

  * @brief ADC MSP De-Initialization

  *        This function frees the hardware resources used in this example:

  *          - Disable the Peripheral's clock

  *          - Revert GPIO to their default state

  * @param hadc: ADC handle pointer

  * @retval None

  */

void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)

{

  /*##-1- Reset peripherals ##################################################*/

  ADCx_FORCE_RESET();

  ADCx_RELEASE_RESET();

  /*##-2- Disable peripherals and GPIO Clocks ################################*/

  /* De-initialize the ADC Channel GPIO pin */

  HAL_GPIO_DeInit(ADCx_CHANNEL_GPIO_PORT, ADCx_CHANNEL_PIN);

}

Philippe Cherbonnel
ST Employee

Hello @CDesh​ ,

Good you have found the cause of your issue.

If it is a matter of interruption occurring too often in your application, leading to interrupt overhead, there is no obvious solution. Some choices have to be done at application level: either slow down interruptions rate is possible, or disable less important peripherals (as you have done), or optimize interruptions priority and manage occurrences missing of the ones with lowest priorities.

Best regards

Philippe