After releasing a firmware update for my custom device, I started noticing that some units were failing to operate correctly. I discovered that writing to the flash memory while the system voltage is below a safe threshold that mentioned in datasheet can lead memory corruption. So every time the software attempted to read from the corrupted flash region, it would consistently trigger an NMI (Non-Maskable Interrupt) due to ECC (Error-Correcting Code) faults.
To protect, I implemented a safeguard in the firmware: if an ECC error is detected during runtime, the system will automatically erase the affected flash region to prevent repeated NMI handler interrupt and restore stability.
This incident led me to a broader question: aside from NMI and HardFault, are there any other exception or fault handlers available on STM32 devices that could be useful in similar scenarios?
I heard there are some errors (MPU Fault Handler, Bus Fault Handler, UsageFault_Handler). Will they also trigger NMI?
