Orbcode Trace functions library
Classes | Enumerations | Functions
Data Watchpoint & Trace Unit

Use DWT to perform PC sampling and trace memory accesses. More...

Classes

struct  DWTOptions
 DWT configuration. More...
 

Enumerations

enum  DWTSyncTap { DWTSyncTapDisabled = 0 , DWTSyncTap24 = 1 , DWTSyncTap26 = 2 , DWTSyncTap28 = 3 }
 Interval of ITM synchronization packet. More...
 
enum  DWTCycleTap { DWTCycleTap6 = 0 , DWTCycleTap10 = 1 }
 Interval of PC sampling and event counter packets. More...
 

Functions

static void DWTSetup (const DWTOptions *options)
 Configures DWT component. More...
 
static void DWTEnableComparator (uint8_t comparator, uintptr_t address, uint8_t ignoreBits, bool emitRange, uint8_t function)
 Configures DWT comparator. More...
 
static void DWTDisableComparator (uint8_t comparator)
 Disables DWT comparator. More...
 

Detailed Description

Use DWT to perform PC sampling and trace memory accesses.

Data Watchpoint & Trace unit provides built-in capabilites for:

DWT outputs data to ITM which forwards it to formatter. When configuring ITM option ITMOptions::ForwardDWT must be enabled.

Relationships between DWT clocks and packets

Reference: ARMv7-M Architecture Reference Manual, chapter C1.8 The Data Watchpoint and Trace unit

Enumeration Type Documentation

◆ DWTSyncTap

enum DWTSyncTap

Interval of ITM synchronization packet.

See ARMv7-M Architecture Reference Manual, section C1.8.3 "CYCCNT cycle counter and related timers" for details

Enumerator
DWTSyncTapDisabled 

Disabled.

DWTSyncTap24 

Output synchronization when CYCCNT[24] bit changes.

\(PacketRate = \frac{ProcessorClock}{16 \cdot 10^6{}}\)

DWTSyncTap26 

Output synchronization when CYCCNT[26] bit changes.

\(PacketRate = \frac{ProcessorClock}{64 \cdot 10^6{}}\)

DWTSyncTap28 

Output synchronization when CYCCNT[28] bit changes.

\(PacketRate = \frac{ProcessorClock}{16 \cdot 256^6{}}\)

◆ DWTCycleTap

Interval of PC sampling and event counter packets.

See ARMv7-M Architecture Reference Manual, section C1.8.3 "CYCCNT cycle counter and related timers" for details

Enumerator
DWTCycleTap6 

Output packet when bit CYCCNT[6] changes.

\(POSTCNTClockRate = \frac{ProcessorClock}{64}\)

DWTCycleTap10 

Output packet when bit CYCCNT[10] changes.

\(POSTCNTClockRate = \frac{ProcessorClock}{1024}\)

Function Documentation

◆ DWTSetup()

void DWTSetup ( const DWTOptions options)
inlinestatic

Configures DWT component.

Note that there is no validation if specified configuration is valid (e.g. sampling prescaler values) and there are no checks to verify MCU capabilities (enabling exception tracing when it is not implemented).

Parameters
optionsDWT configuration

◆ DWTEnableComparator()

void DWTEnableComparator ( uint8_t  comparator,
uintptr_t  address,
uint8_t  ignoreBits,
bool  emitRange,
uint8_t  function 
)
inlinestatic

Configures DWT comparator.

Comparator might issue a trace packet when specified memory range is accesses for read or write.

Number of comparators is vendor-specific, check with documention how many are available. This function does not check if specified comparator is available.

Comparator can monitor single byte in memory or range by ignoring specified number of least significant bits, e.g. to monitor single uint32_t variable setup address parameter to variable address and ignoreBits parameter to 2

Parameters
comparatorComparator to use
addressWatchpoint base address
ignoreBitsNumber of bits to ignore
emitRangeIf true, DWT will emit packet with actual data access address. if false - packet with program counter that resulted in memory access.
functionComparator function, see ARMv7-M Architecture Reference Manual, table C1-14 for list of available functions

◆ DWTDisableComparator()

void DWTDisableComparator ( uint8_t  comparator)
inlinestatic

Disables DWT comparator.

Number of comparators is vendor-specific, check with documention how many are available. This function does not check if specified comparator is available.

Parameters
comparatorComparator to disable