Appendix E

Debug Registers Quick Reference

E.1. Overview

The debug systems in the Cortex®-M0 and Cortex-M0+ processors contain a number of programmable registers. These registers can be accessed by in-circuit debuggers only and cannot be accessed by the application software. This quick reference is intended for tools developers, or if you are using a debugger that supports debug scripts (e.g., ARM® DS-5), where you can use debug scripts to access these registers to carry out testing operations automatically.
The debug system in the Cortex-M0 and the Cortex-M0+ processors is partitioned into as follows:
• Debug support in the processor core,
• Breakpoint unit,
• Data watchpoint unit,
• ROM table,
• and optionally, a Micro Trace Buffer (MTB) for Cortex-M0+ processor.
System-on-Chip developers can add additional debug support components if required. If additional debug components are added, an additional ROM table unit could also be added to the system so that a debugger can identify available debug components included in the system.
The debug support is configurable; for example, some Cortex-M0/M0+ devices might not have any debug support, and some Cortex-M0+ devices might not have MTB support.

E.2. Core Debug Registers

The processor core contains a number of registers for debug purpose (Table E.1).

Table E.1

Summary of core debug registers

AddressNameDescriptions
0xE000ED24SHCSRSystem Handler Control and State Register—indicate system exception status.
0xE000ED30DFSRDebug Fault Status Register—Allow debugger to determine the cause of halting.
Table Continued

image

AddressNameDescriptions
0xE000EDF0DHCSRDebug Halting Control and Status Register—Control processor debug activities like halting, single stepping
0xE000EDF4DCRSRDebug Core Register Selector Register—control read and write of core registers during halt
0xE000EDF8DCRDRDebug Core Register Data Register—data transfer register for reading or writing core registers during halt
0xE000EDFCDEMCRDebug Exception Monitor Control Register—for enabling of data watchpoint unit and vector catch feature. Vector catch allows the debugger to halt the processor if the processor is reset, or if a HardFault exception is triggered.
0xE000EFD0 to 0xE000EFFCPIDs, CIDsID registers

image

System Handler Control and State Register (0xE000ED24)
BitsFieldTypeReset valueDescriptions
31:16ReservedReserved
15SVCALLPENDEDRO01 indicates SVC execution is pended.
Accessible from debugger only.
14:0ReservedReserved

image

Debug Fault Status Register (0xE000ED30)
BitsFieldTypeReset valueDescriptions
31:5ReservedReserved
4EXTERNALRWc0EDBGRQ was asserted
3VCATCHRWc0Vector catch occurred
2DWTTRAPRWc0Data watchpoint occurred
1BKPTRWc0Breakpoint occurred
0HALTEDRWc0Halted by debugger or single stepping

image

Debug Halting Control and Status Register (0xE000EDF0)
BitsFieldTypeReset valueDescriptions
31:16DBGKEY (during write)WODebug Key. During write, the value of 0xA05F must be used on the top 16 bit. Otherwise the write is ignored.
25S_RESET_ST (during read)ROReset status flag (sticky). Core has been reset or being reset; this bit is clear on read.
24S_RETIRE_ST (during read)ROInstruction is completed since last read; this bit is clear on reset.
Table Continued

image

BitsFieldTypeReset valueDescriptions
19S_LOCKUPROWhen this bit is 1, the core is in lock up state
18S_SLEEPROWhen this bit is 1, the core is sleeping
17S_HALT (during read)ROWhen this bit is 1, the core is halted.
16S_REGRDY_ST (during read)ROWhen this bit is 1, the core is ready for a register read or register write operation.
15:4ReservedReserved
3C_MASKINTSR/W0Mask exceptions while stepping (does not affect NMI and hard fault); valid only if C_DEBUGEN is set.
2C_STEPR/W0Single step control. Set this to 1 to carry out single step operation; valid only if C_DEBUGEN is set.
1C_HALTR/W0Halt control. This bit is only valid when C_DEBUGEN is set.
0C_DEBUGENR/W0Debug enable. Set this bit to 1 to enable debug.

image

Debug Core Register Selector Register (0xE000EDF4)
BitsFieldTypeReset valueDescriptions
31:17ReservedReserved
16REGWnRWOSet to 1 to write value to register
Set to 0 to read value from register
15:5ReservedReserved
4:0REGSELWO0Register select

image

Debug Core Register Data Register (0xE000EDF8)
BitsFieldTypeReset valueDescriptions
31:0DBGTMPRW0Data value for the core register transfer

image

Debug Exception and Monitor Control Register (0xE000EDFC)
BitsFieldTypeReset valueDescriptions
31:25ReservedReserved
24DWTENARW0Data Watchpoint unit enable.
23:11ReservedReserved
10VC_HARDERRRW0Debug trap at hard fault exception
9:1ReservedReserved
0VC_CORERESETRW0Halt processor after system reset and before the first instruction executed.

image

E.3. Breakpoint Unit

The breakpoint unit contains up to four comparators for instruction breakpoints. Each comparator can produce a breakpoint for up to two instructions (if the two instructions are located in the same word address). Additional breakpoints can be implemented by inserting breakpoint instructions in the program image if the program memory can be modified (Table E.2).
The breakpoint unit design is configurable. Some microcontrollers might contain no breakpoint unit, or a breakpoint unit with less than four comparators.

Table E.2

Summary of registers in the breakpoint unit

AddressNameDescriptions
0xE0002000BP_CTRLBreakpoint Control Register—for enabling the breakpoint unit and provide information about the breakpoint unit.
0xE0002008BP_COMP0Breakpoint Comparator Register 0
0xE000200CBP_COMP1Breakpoint Comparator Register 1
0xE0002010BP_COMP2Breakpoint Comparator Register 2
0xE0002014BP_COMP3Breakpoint Comparator Register 3
0xE0002FD0 to 0xE0002FFCPIDs, CIDsID registers
Breakpoint Control Register (0xE0002000)
BitsFieldTypeReset valueDescriptions
31:17ReservedReserved
7:4NUM_CODERO0 to 4Number of comparators
3:2ReservedReserved
1KEYWOWrite Key. When write to this register, this bit should be set to 1, otherwise the write operation is ignored.
0ENABLERW0Enable control

image

Breakpoint Comparator Registers (0xE0002008–0xE0002014)
BitsFieldTypeReset valueDescriptions
31:30BP_MATCHRWBreakpoint setting:
00: No breakpoint
01: Breakpoint at lower half word address
10: Breakpoint at upper half word address
11: Breakpoint at both lower and upper half word
29ReservedReserved
28:2COMPRWCompare instruction address
1ReservedReserved
0ENABLERW0Enable control for this comparator

image

E.4. Data Watchpoint Unit

The data watchpoint unit (DWT) has two main functions:
• Setting data watchpoints
• Providing a Program Counter (PC) sampling register for basic profiling.
Before accessing the DWT, the DWTENA bit in Debug Exception and Monitor Control Register (DEMCR, address 0xE000EDFC) must be set to 1 to enable the DWT. Unlike the Data Watchpoint and Trace unit in Cortex®-M3/M4, the DWT in the Cortex-M0 and Cortex-M0+ processors does not support trace. But the programming models of its registers are mostly compatible to the DWT in ARM®v7-M (Table E.3).
The DWT design is configurable. Some microcontrollers might contain no DWT, or a DWT with just one comparator.

Table E.3

DWT register summary

AddressNameDescriptions
0xE0001000DWT_CTRLDWT Control Register—provide information about the data watchpoint unit.
0xE000101CDWT_PCSRProgram Counter Sample Register—provide current program address
0xE0001020DWT_COMP0Comparator Register 0
0xE0001024DWT_MASK0Mask Register 0
0xE0001028DWT_FUNCTION0Function Register 0
0xE0001030DWT_COMP1Comparator Register 1
0xE0001034DWT_MASK1Mask Register 1
0xE0001038DWT_FUNCTION1Function Register 1
0xE0001FD0 to 0xE0001FFCPIDs, CIDsID registers
DWT Control Register (0xE0001000)
BitsFieldTypeReset valueDescriptions
31:28NUMCOMPRO0 to 2Number of comparator implemented
27:0ReservedReserved

image

Program Counter Sample Register (0xE000101C)
BitsFieldTypeReset valueDescriptions
31:0EIASAMPLEROExecution instruction address sample. Read as 0xFFFFFFFF is core is halted or if DWTENA is 0.

image

DWT COMP0 Register and DWT COMP1 Registers (0xE0001020, 0xE0001030)
BitsFieldTypeReset valueDescriptions
31:0COMPRWAddress value to compare to. The value must be aligned to the compare address range defined by the compare mask register.

image

DWT MASK0 Register and DWT MASK1 Registers (0xE0001024, 0xE0001034)
BitsFieldTypeReset valueDescriptions
31:4ReservedReserved
3:0MASKRWMask pattern:
0000: compare mask = 0xFFFFFFFF
0001: compare mask = 0xFFFFFFFE

1110: compare mask = 0xFFFFC000
1111: compare mask = 0xFFFF8000

image

DWT FUNC0 Register and DWT FUNC1 Registers (0xE0001028, 0xE0001038)
BitsFieldTypeReset valueDescriptions
31:4ReservedReserved
3:0FUNCRW0Function:
0000: Disabled
0100: Watchpoint on PC match
0101: Watchpoint on read address
0110: Watchpoint on write address
0111: Watchpoint on read or write address
Other values: Reserved

image

E.5. ROM Table Registers

The ROM table is used to allow a debugger to identify available components in the system. The lowest two bits of each entry are used to indicate if the debug component is present, and if there is another valid entry following in the next address in the ROM table. The rest of the bits in the ROM table contain the address offset of the debug unit from the ROM table base address.
AddressValueNameDescriptions
0xE00FF0000xFFF0F003SCSPoints to System Control Space base address 0xE000E000
0xE00FF0040xFFF02003DWTPoints to DW base address 0xE0001000
0xE00FF0080xFFF03003BPUPoints to BPU base address 0xE0002000
0xE00FF00C0x00000000endEnd of table marker
0xE00FFFCC0x00000001MEMTYPEIndicates that system memory is accessible on this memory map.
0xE00FFFD0 to 0xE00FFFFC0x000000––IDsPeripheral ID and component ID values (values dependent on the design versions).

image

Using the ROM table, the debugger can identify the debug components available as shown in Figure E.1.
The ROM table look-up can be divided into multiple stages if a System-on-Chip design contains additional debug components and an extra ROM table. In such cases the ROM table look-up can be cascaded, as shown in Figure E.2, so that the debugger can identify all the debug components available.
image
Figure E.1 Debuggers can use the ROM table to detect available debug components automatically.
image
Figure E.2 Multistage ROM table look-up when additional debug components are present.

E.6. Micro Trace Buffer

E.6.1. Overview

The MTB component provides instruction trace feature for the Cortex®-M0+ processor (Table E.4). It is an optional component and the base address of the MTB is device dependent. The full details of the MTB are covered in the CoreSight™ MTB-M0+ Technical Reference Manual (TRM, reference 15), which can be downloaded from ARM® Web site.

Table E.4

Summary of the MTB registers

AddressNameDescriptions
Base address + 0x0POSITIONPosition of the trace pointer
Base address + 0x4MASTERVarious control information, including memory size allocated for trace buffer.
Base address + 0x8FLOWControl watermark level, and what actions to take when the trace pointer reached water mark level.
Base address + 0xCBASEThe base address of the SRAM
Base address + 0xF00 to 0xFFCCoreSight registersRegisters for CoreSight device management and identifications

E.6.2. POSITION Register

BitsFieldTypeReset valueDescriptions
31:N0Unimplemented bits of POINTER.
Read as zero, write ignored.
N:3POINTERRWRelative address for the next trace packet (the address must be multiple of 8 because each packet contains two words).
Width of POINTER depends on the SRAM size connected to the MTB.
Physical address of pointer is POINTER + BASE.
2WRAPRWThis bit is set to 1 automatically when the POINTER value wraps when reaching to the end of the allocated space.
1:0Reserved

image

E.6.3. MASTER Register

BitsFieldTypeReset valueDescriptions
31ENRW0Trace Enable
30:10Reserved
9HALTREQRW0Halt request bit. This bit is automatically set to 1 when the watermark level is reached and AUTOHALT bit is set. When this bit is set, the MTB assert an External Debug Request (EDBGRQ) to the processor top stop put the processor into halt debug mode.
8RAMPRIVRW0When set to 1, only privileged access is allowed to the SRAM. Otherwise both privileged and unprivileged code can access to the SRAM connected to the MTB.
7SFRWRPRIVRW1When set to 1, only privileged access is allowed to the MTB registers. Otherwise both privileged and unprivileged code can access to the MTB registers.
6TSTOPENRW0When set to 1, enable the use of external signal to control stopping of trace.
5TSTARTENRW0When set to 1, enable the use of external signal to control starting of trace.
4:0MASKRWDetermine the SRAM size allocated for instruction trace (define the MSB of the POSITION.POINTER field that can be increment).
0–16 bytes
1–32 bytes

6–1 KB
7–2 KB
8–4 KB

image

E.6.4. FLOW Register

BitsFieldTypeReset valueDescriptions
31:3POINTERRWAddress for the next trace packet (the address must be multiple of 8 because each packet contains two words).
2Reserved
1AUTOHALTWhen set to 1, automatically halt processor (via EDBGRQ signal) when watermark level is reached.
0AUTOSTOPRW0When set to 1, automatically stop tracing when watermark level is reached

image

E.6.5. BASE Register

BitsFieldTypeReset valueDescriptions
31:0SRAMBASEROIndicate the base address of the SRAM connected to the MTB

image

E.6.6. Packet Format

Each of the MTB packets is two words in size (Figure E.3). The packet address must be aligned to multiple of 8 bytes.
image
Figure E.3 An MTB packet.
Since an instruction address must be aligned to half-word aligned address, the bit 0 of each word in an MTB packet can be used for other information, the S bit and A bit (Table E.5):

Table E.5

Definition of the S bit and A bit in an MTB packet

BitDescriptions
S bitStart bit. If this bit is 1, it indicates that the trace was previously has been stopped and this packet is the start of a new sequence. During a trace session, the trace could be stopped and started again using external controlled signal (when MASTER.TSTARTED and MASTER.TSTOPED bits are set)
A bitAtomic bit. Indicates the type of branch.
If this bit is 0, it indicates a normal branch operation. The source address field indicates the address of the instruction that trigger the branch.
If this bit is 1, it indicates exception entry or a PC update in a debug state. The source address field indicates the return address for the exception, or the address of the instruction that was to be executed before entering debug state.
In exception returns, two MTB packets are generated (Figure E.4).
image
Figure E.4 Two packets are generated for an exception return.

E.6.7. Examples

Take an example that a microcontroller has an SRAM connected to the MTB which is 32 KB in size, and the address of the SRAM is at 0x20000000 (Figure E.5). The BASE register should read as 0x20000000.
image
Figure E.5 Layout of SRAM usage in example.
Since the size of the SRAM is 32 KB, only bit[14:2] of the POSITION register is implemented. A debugger can detect the maximum size of the SRAM by writing 0xFFFFFFF8 to the POSITION register, and get 0x00007FF8 back.
For instruction trace, we would like to allocate only the last 4 KB of the SRAM. The first 28 KB of the SRAM is still used by the application code.
To enable such arrangement, we can program the MTB as:
• POSITION = 0x00007000 (Trace buffer starting address = BASE + 0x00007000)
• FLOW = 0 (watermark)
• MASTER = 0x80000008 (FIELD = 0x8, the highest bit that can be toggled by pointer increment is bit 8 (512 × 8 bytes = 4 KB). EN bit set to 1 to enable trace)
To disable trace, we can just clear the EN bit in MASTER:
• MASTER = 0x00000008
After the trace is done, the debugger can read the POSITION register to deter the ending location of the trace, read the trace buffer backward and identify the start of the trace by checking the S-bit. If the TSTARTEN and TSTOPEN bits are used in the trace setup, there can be multiple trace sessions and the debugger should read through the whole 4 KB allocated buffer to see if there are multiple sessions of instruction trace.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.79.88