I am playing with debugging STM32F407 via JTAG protocol and DAP interface etc. I want to use the DHCSR register to stop the processor (set the C_HALT bit in this register). And to do this through the interface DAP need to configure the register CSW, write the address of DHCSR in the register TAR and the necessary data in the register DRW, all this I do but after all this procedure I constantly get an error STICKYERR in the DAP register CTRL/STAT and accordingly can not read the register DHCSR or write to it. What I do wrong?
I attempted to halt the STM32F407 processor using the DHCSR register via the JTAG protocol and DAP interface. My steps:
- Write
0b1010(theDPACCregister code) into theIRregister. - Some settings in the
APregisterCSWneed to be configured. To access this register, we need to select the correspondingAPand register bank in theDP SELECTregister. Write to theDRregister:- DATA[31:0] =
0x00- APSEL[31:24] =
0x00 - APBANKSEL[7:4] =
0x00
- APSEL[31:24] =
- A[3:2] =
0b10(address ofSELECTregister) - RnW =
0b0
- DATA[31:0] =
- Next, we need to write the
CSWregister. Since this is anAPregister, we need to use theAPACCregister to access it:- Write
0b1011(theAPACCregister code) into theIRregister.
- Write
- Form the data for the configuration: set the data size for writing to 32-bits (
Size[0:2] = 0b010), disable the auto-increment function of the address (AddrInc[5:4] = 0b00). Write toDR:- DATA[31:0] =
0x2200 0002(MasterType=1, Hprot1=1, Size=b010) - A[3:2] =
0b00(address ofCSWregister) - RnW =
0b0
- DATA[31:0] =
- Then we need to set the address of the memory cell to which we want to write the data. This is done through the
APregisterTAR. And since this register belongs to the sameAPasCSWand is in the same bank, we can omit the reference to theDP SELECTregister and immediately write the address value. Write toDR:- DATA[31:0] =
0xE000EDF0 - A[3:2] =
0b01(address ofTARregister) - RnW =
0b0
- DATA[31:0] =
- The last step is to actually write the data. To do this, we need to write them to the
DRWregister. Write toDRW:- DATA[31:0] =
0x03 - A[3:2] =
0b11(address ofDRWregister) - RnW =
0b0
- DATA[31:0] =
After this I got STICKYERR in the DAP register `CTRL/STAT.