Skip to main content
Explorer
April 20, 2024
Question

STM32c0. Issue in push button on external interrupt example

  • April 20, 2024
  • 4 replies
  • 3233 views

Hi All

I'm new to STM32 and I'm exploring it a little bit. I think I've found an issue in the HAL 

 

in configuration Line is referred to the external interrupt line to be connected.

 

it is configured in the BSP with  (void)HAL_EXTI_GetHandle(&hpb_exti[Button], BUTTON_EXTI_LINE[Button]);

 

where static const uint32_t BUTTON_EXTI_LINE[BUTTONn] = {BUTTON_USER_EXTI_LINE}; and BUTTON_USER_EXTI_LINE is 0x2000;

 

the problem is in the usage of Line (in all the  stm32c0xx_hal_exti.c file!)

STDoom_0-1713646283415.png

linepos is almost always 0 since EXTI_PIN_MASK is 1 and this is wrong. Removing the & all seems to work properly.

Since it one of the first test that I'm doing with the ST IDE and HAL might be I'm doing something wrong :D  

 

 

 

    This topic has been closed for replies.

    4 replies

    ST Employee
    April 22, 2024

    Hello @STDoom , 

     

    First of all, welcome in the ST community. 

    Is it possible to send you code ? Because I tried to have an EXTI interrupt with the BUTTON_USER and I'm facing no issue and it is working fine. 

     

    Best regards,

     

    Simon

    STDoomAuthor
    Explorer
    April 22, 2024

    Hi

    I've just created the example for the demoboard  NUCLEO- STM32C0.

    If it might help later I'll copy here the project but I think was this one (https://wiki.st.com/stm32mcu/wiki/Getting_started_with_EXTI)

    STDoomAuthor
    Explorer
    April 22, 2024

    here the example. I've created a new empty project for the selected board Nucleo C031C6 adding the BSP selecting the led + the button (NO VCM) and generate the example code.

    For some reason it doesn't run on my board as is so I've changed the clock set up (to use HSI not the HSE) 

    ST Employee
    April 23, 2024

    Hello @STDoom ,

     

    I confirmed your issue and I have submitted an internal ticket addressing your request to the dev team.

    Internal ticket number: 179773 (This is an internal tracking number and is not accessible or usable by customers).

    Your workaround is working. Thanks for your contribution.

     

    Best regards,

     

    Simon

    ST Employee
    May 27, 2024

    Hello @STDoom ,

     

    To fix the issue in the bsp header file "stm32c0xx_nucleo.h" line 191 you need to replace this code:

    #define BUTTON_USER_EXTI_LINE GPIO_PIN_13

    by this code:

    #define BUTTON_USER_EXTI_LINE EXTI_LINE_13

     

    This will be implemented for the Cube FW revision.

     

    Best regards,

     

    Simon

    Explorer II
    October 30, 2024

    In this same example, now when code is generated for Nucleo board C031C06, STM32CubeIDE generates this code in the file stm32c0xx_it.c:

    HAL_EXTI_IRQHandler(&H_EXTI_13);

    but when try to compile, it says:

    ../Core/Src/stm32c0xx_it.c:151:24: error: 'H_EXTI_13' undeclared (first use in this function) 151 | HAL_EXTI_IRQHandler(&H_EXTI_13);

    Making it unusable. Is there a way to solve it?

    Graduate II
    December 30, 2024

    I too noticed the issue that H_EXTI_13 was not defined by STM32CubeMX, when using a NUCLEO-H723ZG, STM32CubeMX 6.13.0, STM32CubeIDE 1.17.0.

    You could define it yourself in stm32h7xx_nucleo.h, past the point of the decalartion of enum BUTTON_USER, I would sugest line 170, something like:

     

    #define H_EXTI_13 hpb_exti[BUTTON_USER]

     

    Be aware when STM32CubeMX regenerates the code, it may kill it again.
    Since you sometimes need to fix HAL bugs, or add enhancements (for example LAN8742), or support for greater capacity EMMC memories, where there aren't user sections, it's best to NOT let STM32CubeMX interfere with your project, once starting off. It's probably more safe to use a separate directory if you want to add stuff later, and add/compare that against your project. Meld could be very useful for that, for example.