Skip to main content
vtran1
Associate III
August 22, 2019
Solved

What is the differences between "EXTI_Callback" and "EXTI_IRQHandler"?

  • August 22, 2019
  • 1 reply
  • 2964 views

In the sample code, STM uses "HAL_GPIO_EXTI_Callback" to handle interrupt from a push button, but in class I learnt that we need to use the IRQHandler to handle the interrupt. When to use "HAL_GPIO_EXTI_Callback" and "HAL_GPIO_EXTI_IRQHandler" to handle interrupt?

This topic has been closed for replies.
Best answer by Tesla DeLorean

The IRQ Handler is the thing that actually gets called by the NVIC, you then call into the HAL via HAL_GPIO_EXTI_IRQHandler(), and then it in turn calls your callback functions if it validates a specific source, it also then clears the source as it leaves.

HAL just layers on some extra complexity, you can chose to use or ignore that if you wish.

/**

 * @brief This function handles external line 15_10 interrupt request.

 * @param None

 * @retval None

 */

void EXTI15_10_IRQHandler(void) // << Processor goes here via Vector Table

{

 HAL_GPIO_EXTI_IRQHandler(USER_BUTTON_PIN); // >> Goes INTO HAL here, and then out to your callback

}

1 reply

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
August 22, 2019

The IRQ Handler is the thing that actually gets called by the NVIC, you then call into the HAL via HAL_GPIO_EXTI_IRQHandler(), and then it in turn calls your callback functions if it validates a specific source, it also then clears the source as it leaves.

HAL just layers on some extra complexity, you can chose to use or ignore that if you wish.

/**

 * @brief This function handles external line 15_10 interrupt request.

 * @param None

 * @retval None

 */

void EXTI15_10_IRQHandler(void) // << Processor goes here via Vector Table

{

 HAL_GPIO_EXTI_IRQHandler(USER_BUTTON_PIN); // >> Goes INTO HAL here, and then out to your callback

}

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..