EasyManua.ls Logo

ARM Cortex-R4 - Page 344

Default Icon
436 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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 on page 12-14.
Example 12-22 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);
}
Example 12-23 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, 0xEE000E15 + (Rd<<12));
// Step 2. Read the register value through the DCC. Read stalls until
// DBGDTRTX is ready
reg_val := ReadDebugRegister(32);
return reg_val;
}
Example 12-24 on page 12-71 shows the sequence to write registers in stall mode.

Table of Contents

Related product manuals