cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 INTERRUPTION

MalekKhadhraoui
Visitor

Hi am relatively new to stm32 development.
I would like to understand the difference between HAL_GPIO_EXTI_CLEAR_IT and HAL_GPIO_EXTI_CLEAR_FLAG 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
STOne-32
ST Employee

Dear @MalekKhadhraoui ,

Welcome in STCommunity and in STM32 MCUs, 

I tried to ask ChatGPT the same question and here some inputs:

Key Differences:

HAL_GPIO_EXTI_CLEAR_IT clears the interrupt pending flag, which is used to signal that an interrupt event has occurred and needs to be processed. This is typically used in the interrupt service routine.

HAL_GPIO_EXTI_CLEAR_FLAG clears the EXTI flag itself, which signifies that the external interrupt event has been detected on a GPIO pin.

 

In most cases, you’d use HAL_GPIO_EXTI_CLEAR_IT inside the interrupt handler, and HAL_GPIO_EXTI_CLEAR_FLAG when manually managing or troubleshooting the interrupt flags.

In essence:

  • HAL_GPIO_EXTI_CLEAR_IT clears the interrupt pending flag in the PR register
  •  HAL_GPIO_EXTI_CLEAR_FLAG clears the EXTI flag in the PR register.

The difference in the HAL functions primarily comes from their abstraction level and naming conventions, but at the register level, both do the same thing.

Hope that helps clarify the difference! Let me know if you have any more questions.

Ciao 

STOne-32 { the answer was generated by ChatGPT and adjusted a bit , it seems  not so bad :-)} 

View solution in original post

2 REPLIES 2
STOne-32
ST Employee

Dear @MalekKhadhraoui ,

Welcome in STCommunity and in STM32 MCUs, 

I tried to ask ChatGPT the same question and here some inputs:

Key Differences:

HAL_GPIO_EXTI_CLEAR_IT clears the interrupt pending flag, which is used to signal that an interrupt event has occurred and needs to be processed. This is typically used in the interrupt service routine.

HAL_GPIO_EXTI_CLEAR_FLAG clears the EXTI flag itself, which signifies that the external interrupt event has been detected on a GPIO pin.

 

In most cases, you’d use HAL_GPIO_EXTI_CLEAR_IT inside the interrupt handler, and HAL_GPIO_EXTI_CLEAR_FLAG when manually managing or troubleshooting the interrupt flags.

In essence:

  • HAL_GPIO_EXTI_CLEAR_IT clears the interrupt pending flag in the PR register
  •  HAL_GPIO_EXTI_CLEAR_FLAG clears the EXTI flag in the PR register.

The difference in the HAL functions primarily comes from their abstraction level and naming conventions, but at the register level, both do the same thing.

Hope that helps clarify the difference! Let me know if you have any more questions.

Ciao 

STOne-32 { the answer was generated by ChatGPT and adjusted a bit , it seems  not so bad :-)} 

Thanks a lot!