Skip to main content
Graduate
November 2, 2024
Question

STM32G0 reseted after GPIO interrupt happened

  • November 2, 2024
  • 6 replies
  • 1695 views

Screenshot 2024-11-02 at 15.23.02.png

I'm using gpio interrupt inside there 

void HAL_GPIO_EXTI_Rising_Callback(uint16_t GPIO_Pin){

static uint32_t push_time;

if(GPIO_Pin == IS_FUSED_Pin){

pin_int_now = HAL_GetTick();

if(fuze_push_time + DEBOUNCE_INTERVAL < pin_int_now){

LED_Green_On();

fuze_push_time = pin_int_now;

state = FUSED;

}}}

 

Inside while(1) mostly HAL_Delay(5);

 

ISSUE: some times during pin interrupt happened chip looks like reseted.

 

Gess some error happened and chip reseted. How can debug it and find the reason?

 

 

 

    This topic has been closed for replies.

    6 replies

    Graduate II
    November 2, 2024

    From where you have this name for func and sure this can work, i mean not IRQ exist only once ...

     

    void HAL_GPIO_EXTI_Rising_Callback(uint16_t GPIO_Pin){
    static uint32_t push_time;
    if(GPIO_Pin == IS_FUSED_Pin){
     pin_int_now = HAL_GetTick();
     if(fuze_push_time + DEBOUNCE_INTERVAL < pin_int_now){
     LED_Green_On();
     fuze_push_time = pin_int_now;
     state = FUSED;
    }}}

     

    when interrupt is enabled , but not assign right handler result is reset MCU 

    But for G0 your code seems ok then debug app an place breakpoint in main before while on some init , when break repeats mcu was reset...

    Graduate
    November 2, 2024

    Don't use EXTI interrupt for switches. I keep repeating it every time i see the code using EXTI for switches. If yoy want to use EXTI - in addition to EXTI you must use timer interrupt, but if you use timer interrupt there is no need for EXTI at all.

     

    Anyway, your code is incorrect. maybe it has nothing to do with what you describe as "reset", but it still is incorrect.

    push_time variable is not used.

    This condition is wrong if timer overflow occurs:

    if(fuze_push_time + DEBOUNCE_INTERVAL < pin_int_now)

    BigdanAuthor
    Graduate
    November 2, 2024

    After hour of investigation found the issue but no idea why it happen and how it fix

    Use PA7 as external interrupt source

    Use PA11 for control p- channel mosfet transistor

    When PA11 in low and trigger PA7 pin for interrupt chip reseted!(

    When PA11 in hight and trigger PA7 pin for interrupt works good.

     

     

    BigdanAuthor
    Graduate
    November 2, 2024

    Actually find what going on.  Pin PA11 connected to switch with on push connect mosfet drain to ground chip power go dawn and reset happened. 

     

    If it some possibility on STM32G0 detect low power and in my case turn off mosfet?

    In documentation can not find.

    Graduate II
    November 3, 2024

    Hi,

    The fact that you are trying to debounce within the EXTI callback is evidence that you have a miss understanding of what EXTI does.

    You need to go back to the drawing board with this idea...

    Kind regards
    Pedro

    BigdanAuthor
    Graduate
    November 3, 2024

    Solved the issue. Turn off PA11 mosfet pin inside interrupt handler before ship will go to reset. 

    Graduate
    November 3, 2024

    Read: "masked hardware and software issues with quick-and-dirty fix". ;)