Skip to main content
Visitor II
December 2, 2024
Solved

had to use void HAL_GPIO_EXTI_Falling_Callback and void HAL_GPIO_EXTI_Rising_Callback

  • December 2, 2024
  • 1 reply
  • 1486 views

i used stm32cubeMX to generate code to support GPIO external interrupts.

i expected to use HAL_GPIO_EXTI_Callback and it compiled but did not work.

i had to use HAL_GPIO_EXTI_Falling_Callback and HAL_GPIO_EXTI_Rising_Callback

i used a Nucleo-U5a5ZJ board.

cubeMX  6.12.1

cubeIDE 1.16.1

does anyone know why HAL_GPIO_EXTI_Callback does not work?

I noticed that HAL_GPIO_EXTI_Callback was not in the stm32u5xx_hal_gpio.h file

thanks

phil

 

    This topic has been closed for replies.
    Best answer by Karl Yamashita

    There are other STM32's, like STM32G071, STM32C0xx that are the same. 

    1 reply

    Graduate II
    December 3, 2024

    ST just made 2 callbacks instead of 1. You can make your own callback and call it. Read the pin status as you would normally

     

    uint8_t exti4_pinStatus = 1; // initialize to 1, assuming pin is pulled up
    
    void GPIO_EXTI_Callback(uint16_t GPIO_Pin)
    {
    	if(GPIO_Pin == EXTI_4_Pin)
    	{
    		exti4_pinStatus = HAL_GPIO_ReadPin(EXTI_4_GPIO_Port, EXTI_4_Pin);
    	}
    }
    
    void HAL_GPIO_EXTI_Rising_Callback(uint16_t GPIO_Pin)
    {
    	GPIO_EXTI_Callback(GPIO_Pin);
    }
    
    void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin)
    {
    	GPIO_EXTI_Callback(GPIO_Pin);
    }

     

    Visitor II
    December 3, 2024

    most of your examples say to call

    HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)

     

    is the STM32_U5xx_hal_gpio.c the only library that does not support this function?

    are there any examples that show the use of the code you suggested ?

    thanks

    phil

     

    Graduate II
    December 3, 2024

    There are other STM32's, like STM32G071, STM32C0xx that are the same.