AnsweredAssumed Answered

HAL ADC Generic Driver - STM32Cube

Question asked by xavier.jose on Oct 11, 2017
Latest reply on Oct 12, 2017 by Abhilash Iyer

Hi,

 

I'm very confused on how to use the HAL ADC Generic Driver. I configure the ADC using STM32Cube with all the default settings.

 

Now I want to start the ADC and handle the interrupt. Looking into the documentation (UM1785) I read:

 

1 - ADC conversion by interruption:

1.1 - Activate the ADC peripheral and start conversions using function HAL_ADC_Start_IT()

1.2 - Wait for ADC conversion completion by call of function HAL_ADC_ConvCpltCallback() (this function must be implemented in user program)

1.3 - Retrieve conversion results using function HAL_ADC_GetValue() Stop conversion and disable the ADC peripheral using function HAL_ADC_Stop_IT()

However STM32Cube had generated a IRQ Handler for adc on stm32f0xx_it.c:

/**

* @brief This function handles ADC interrupt.

*/

void ADC1_IRQHandler(void)

{

   /* USER CODE BEGIN ADC1_IRQn 0 */

 

   /* USER CODE END ADC1_IRQn 0 */

   HAL_ADC_IRQHandler(&hadc);

   /* USER CODE BEGIN ADC1_IRQn 1 */

 

   /* USER CODE END ADC1_IRQn 1 */

}

My questions are:

1 - Why there is a HAL_ADC_IRQHandler() inside the ADC1_IRQHandler?

2 - Should I use this function to write my code and get adc value?

3 - Should I implement HAL_ADC_ConvCpltCallback() ?

Outcomes