What to do, when enabling interrupt in a program causes other effects of the program (e.g. "heartbeat" blinking in main loop) to freeze?
To certain extent, this situation is similar to the previous issue, and some of the steps mentioned there are usable here, too. Debugging now might start perhaps with stopping the program in the debugger and observing, "where did it go".
Some of the root causes may be:
- ISR does not clear the flag in the peripheral, which invoked the interrupt
- ISR takes too long to execute (often inappropriately calling routines such as
printf()) while the peripheral invokes it too often
- ISR contains a software bug, leading to infinite looping inside the ISR (a nasty variant of this bug is a loop waiting for a hardware flag, which won't be changed under certain circumstances, e.g. when debugger is not connected)
- ISR contains a software bug, resulting in the program ending in some of the fault handlers (usually HardFault)
- ISR name doesn't match the prototype in the ISR table, and falls into the "catch all unspecified interrupts" routine.
- SCB_VTOR is not set appropriately in a program which is not located at the default position in FLASH (0x0800'0000) - usually in an environment with custom bootloader