6.5.8.4.12 Set Stack Pointer

To transfer a data word to an Arm core register, special-purpose register, or Floating-point extension register, a debugger:

  • Writes the required word (PC value) to DCRDR
  • Writes to the DCRSR, with the REGSEL value indicating the required register and the REGWnR bit set to ‘1’ to indicate a write access. This write clears the DHCSR S_REGRDY bit to ‘0’.
  • If required, polls DHCSR until DHCSR.S_REGRDY reads as ‘1’. This indicates that the processor has transferred the DCRDR value to the selected register.

Reference: ARM DDI 0403E.b, C1.6.4 Debug Core Register Data Register, DCRDR

Table 6-38. Set Stack Pointer Sequence
Stepsrddi_dap
WriteD32(DCRDR, Stack Pointer Value)
WriteD32(DCRSR, (Address | REGWnR = 1))
Poll DHCSR for S_REGRDY
Note: This sequence is similar to the Set Program Counter sequence, but it involves accessing a different register.