7.5.1 Enter the Debug Mode

To force the processor to enter the Debug state as soon as it comes out of Reset, a debugger sets DHCSR.C_DEBUGEN to 1 to enable halting debug and sets DEMCR.VC_CORERESET to 1 to enable vector catch on the Reset exception.

When the processor comes out of Reset, it sets DHCSR.C_HALT to 1 and enters the Debug state.

For more details, refer to the ARM v7-M Architecture Reference Manual - ARM DDI 0403E, Debug and Reset.

Table 7-3. Reference
StepsCommands
Enable DebugWriteD32(DHCSR, (DBGKEY | C_DEBUGEN))
Enable Reset Vector CatchWriteD32(DEMCR, VC_CORERESET)
Issue HaltWriteD32(DHCSR, (DBGKEY | C_HALT))