7.5.14 Single Step

To single step CPU instructions, a debugger needs to:

  • Ensure the CPU is in the Debug state by reading the DHCSR.S_HALT bit and place the CPU in the Debug state if this is not the case
  • Write DHCSR = C_MASKINTS | C_STEP | C_DEBUGEN
  • Write DHCSR = C_MASKINTS | C_HALT | C_DEBUGEN

For more details, refer to the ARMv7-M Architecture Reference Manual - ARM DDI 0403E, C1.5.1 Debug stepping.

Table 7-12. Reference
StepsCommands
Single stepWriteD32(DHCSR, DBGKEY | C_MASKINTS | C_STEP | C_DEBUGEN)
Ensure halt after stepWriteD32(DHCSR, DBGKEY | C_MASKINTS | C_HALT | C_DEBUGEN)