cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0 reseted after GPIO interrupt happened

Bigdan
Associate II

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?

 

 

 

7 REPLIES 7
MM..1
Chief III

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...

gbm
Lead III

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)

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
Bigdan
Associate II

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.

 

 

Bigdan
Associate II

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.

PGump.1
Senior III

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

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.
Bigdan
Associate II

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

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

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice