2024-11-02 06:39 AM
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?
2024-11-02 06:51 AM - edited 2024-11-02 06:55 AM
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...
2024-11-02 09:44 AM
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)
2024-11-02 01:38 PM
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.
2024-11-02 02:33 PM
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.
2024-11-02 06:07 PM
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
2024-11-03 04:47 AM
Solved the issue. Turn off PA11 mosfet pin inside interrupt handler before ship will go to reset.
2024-11-03 04:49 AM
Read: "masked hardware and software issues with quick-and-dirty fix". ;)