![ARM Cortex-R4 Скачать руководство пользователя страница 344](http://html.mh-extra.com/html/arm/cortex-r4/cortex-r4_technical-reference-manual_2973229344.webp)
Debug
ARM DDI 0363G
Copyright © 2006-2011 ARM Limited. All rights reserved.
12-70
ID073015
Non-Confidential
Example 12-21 Reading a word of memory
uint32 ReadWord(uint32 address, bool &aborted)
{
// Step 1. Save the value of R0.
saved_r0 := ReadRegister(0);
// Step 2. Write the address to R0.
WriteRegister(0, address);
// Step 3. Execute instruction LDC p14, c5, [R0] through the DBGITR.
ExecuteARMInstruction(0xED905E00);
// Step 4. Read the value from the DTR directly.
datum := ReadDCC();
// Step 5. Restore the corrupted register R0.
WriteRegister(0, saved_r0);
// Step 6. Check the DBGDSCR for a sticky abort.
aborted := CheckForAborts();
return datum;
}
Fast register read/write
When multiple registers must be read in succession, you can optimize the process by placing the
DCC into stall mode and by writing the value 1 to the DCC access mode bits. For more
information, see
CP14 c1, Debug Status and Control Register
shows the sequence to change the DTR access mode.
Example 12-22 Changing the DTR access mode
SetDTRAccessMode(int mode)
{
// Step 1. Write the mode value to DBGDSCR[21:20].
dscr := ReadDebugRegister(34);
dscr := (dscr & ~(0x3<<20)) | (mode<<20);
WriteDebugRegister(34, dscr);
}
shows the sequence to read registers in stall mode.
Example 12-23 Reading registers in stall mode
ReadRegisterStallMode(int Rd)
{
// Step 1. Write the opcode for MCR p14, 0, Rd, c5, c0 to the DBGITR.
// Write stalls until the DBGITR is ready.
WriteDebugRegister(33, 0xEE (Rd<<12));
// Step 2. Read the register value through the DCC. Read stalls until
// DBGDTRTX is ready
reg_val := ReadDebugRegister(32);
return reg_val;
}