cancel
Showing results for 
Search instead for 
Did you mean: 

NMI and Hardfault interrupt issue

usama.s
Associate

Softwares Details:

µVision IDE : version 5.31.0.0

STM32CubeMx : version 5.4.0

Hardware Details:

Mcu: STM32G030K6T6

Programmer : STLink-V3Mini

Work Description:

I configured 3 pins of mcu as external interrupts triggering on both rising and falling edges from STM32cubeMx. Now when i press buttons interrupts and every thing is working fine in code but sometimes it mess up.

Problem:

The issue iam currently facing is sometimes when i press buttons due to some reason NMI or HardFault interrupts occur and code stuck into NMI_Handler or HardFault_Handler functions in the c file stm32g0xx_it.c.

I spent hours on debugging but couldn't figure out the problem. Any help would be appreciated!

Attached is .rar file of complete project.

1 REPLY 1

>>I spent hours on debugging but couldn't figure out the problem. 

With hard faults you need to look critically at the MCU registers and the code at and approaching the fault. There's usually a pretty distinct reason for a failure.

For Keil make sure the stack size is adequate, check size in startup.s, check usage/depth

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..