6.5.8.4.1 Enter Debug Mode

Since the PIC32CM PL10 devices have a Boot ROM, the Reset vector catch cannot be used to prevent the CPU from executing the first instruction in the First Mutable Executable (FME), because the vector catch would halt the CPU on the first instruction in the Boot ROM while the device is locked (DAL = 0).

To force the processor to enter the Debug state as soon as possible, and before executing the FME, the debugger must maneuver the Boot ROM into Park mode. Thereafter, the debugger sets DHCSR.C_DEBUGEN to ‘1’ to enable halting debug, and DHCSR.C_HALT to ‘1’ to enter Debug state.

Reference: ARM DDI 0403E.b, C1.4.1 Entering Debug state on leaving reset state

Table 6-27. Enter Debug Mode Sequence
Stepsrddi_dap
Enable DebugWriteD32(DHCSR, (DBGKEY | C_DEBUGEN))
Issue HaltWriteD32(DHCSR, (DBGKEY | C_HALT))