AN4989 Rev 3
59/118
AN4989
Exception handling
117
In order to trap the exception, a hardware or a software breakpoint can be set in the IDE or
directly programmed in the source code using Arm
®
instruction BKPT.
Caution:
BKPT is not tolerated if no debugger is connected (refer to
microcontroller debugging on page 92
). it is advised to set it under
#ifdef
statement.
In-line insertion of assembly instruction in application C code depends on the IDE.
•
IAR™ EWARM and STM32CubeIDE
void NMI_Handler(void)
{
#ifdef DEBUG
asm ("BKPT 0");
#endif
}
•
Keil
®
void NMI_Handler(void)
{
#ifdef DEBUG
__asm
{
BKPT 0
}
#endif
}
For each IDE, it is also possible to use the abstraction function defined in the CMSIS library
and provided in STM32Cube software pack.
void NMI_Handler(void)
{
#ifdef DEBUG
__BKPT(0);
#endif
}
In all cases, the Halt Debug-Mode is entered; it allows to investigate the issue by inspecting
Call Stack and Registers content.
Tip:
On Keil
®
MDK-Arm µVISION, the caller code is not directly accessible in the Call
Stack Window. Right clicking "Show Caller Code" as in
faulty line.
Содержание STM32 Series
Страница 46: ...Connecting to the board AN4989 46 118 AN4989 Rev 3 Figure 30 Keil hotplug step2 ...
Страница 91: ...AN4989 Rev 3 91 118 AN4989 Debug through hardware exploration 117 Figure 69 STM32F4 F7 dual MCO capabilities ...
Страница 103: ...AN4989 Rev 3 103 118 AN4989 Managing DBGMCU registers 117 Figure 78 Generator Options debug MCU in STM32CubeIDE ...