2016-05-02 03:19 PM
I have a digital input GPIO line where I need an interrupt whenever its input changes. In STM32CubeMX I set this pin to an EXTI line and set the interrupt to trigger on both rising and falling edges.
When, in response to either a rising or falling edge the function HAL_GPIO_EXTI_Callback() is called, is there a way to know whether it was a rising or falling edge that triggered the interrupt? Or will it be necessary to call HAL_GPIO_ReadPin() to infer this? The prototype of the callback is: void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin); What number is the GPIO_Pin parameter set to? Is this the same number I see in STM32CubeMX that follows ''GPIO_EXTI'' when selecting an alternative function for a pin? If so, since this number seems to be same as a pin number within a pin group, if there needs to be such an interrupt for the same pin number in two different groups, is there a way to know the pin's group's letter that triggered the interrupt? What is the difference between and External Event and an External Interrupt? #gpio-exti-interrupt-trigger-edge2016-05-03 03:26 AM
Hi Stephen,
In case of both falling and rising, to recognize the edge type I recommend that in the EXTI_IRQHandler of stm32f'xx_it.c, you create your own Hal_GPIO_EXTI_IRQHandler (uint16_t GPIO_Pin) where you check by calling the HAL_GPIO_ReadPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) which should return GPIO_PIN_SET if rising and GPIO_PIN_SET if falling. Test this and hope that the edge keep its status enough time to be readable. Another solution: you can root the input pin into two EXTI line , one configured as sensitive to rizing edge and the other sensitive to the falling one. If the interrupt occurs one of both IRQ_Handlers is executed and then you know the type of edge. ''What is the difference between and External Event and an External Interrupt?'' > The external event is used in case that you want to wake-up the CPU without executing and IRQ_Handler which is not the case with External Interrupt. -Hannibal-I have a digital input GPIO line where I need an interrupt whenever its input changes. In STM32CubeMX I set this pin to an EXTI line and set the interrupt to trigger on both rising and falling edges.
When, in response to either a rising or falling edge the function HAL_GPIO_EXTI_Callback() is called, is there a way to know whether it was a rising or falling edge that triggered the interrupt? Or will it be necessary to call HAL_GPIO_ReadPin() to infer this? The prototype of the callback is: void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin); What number is the GPIO_Pin parameter set to? Is this the same number I see in STM32CubeMX that follows ''GPIO_EXTI'' when selecting an alternative function for a pin? If so, since this number seems to be same as a pin number within a pin group, if there needs to be such an interrupt for the same pin number in two different groups, is there a way to know the pin's group's letter that triggered the interrupt? What is the difference between and External Event and an External Interrupt?2023-10-17 06:02 AM
It would be nice to overwrite the Hal_GPIO_EXTI_IRQHandler in stm32l0xx_hal_gpio.c file with a custom version