Home > OS >  Is it possible to read the Cycle Count Register (DWT_CYCCNT) when executing at unprivileged?
Is it possible to read the Cycle Count Register (DWT_CYCCNT) when executing at unprivileged?

Time:05-26

Is it possible to read the Cycle Count Register (DWT_CYCCNT) when executing at unprivileged?

#define DWT_CYCCNT  (*(volatile uint32_t*)(0xE0001004)) /**<  Cycle Count Register */
CycleCount = DWT_CYCCNT; /* Unprivileged read of the Cycle Count Register causes a Bus Fault. */

Related: Measuring clock cycle count on cortex m7

CodePudding user response:

Short answer: no.

Debug registers are located in special reserved address space

The architecture reserves address space 0xE0000000 to 0xFFFFFFFF for system-level use. ARM reserves the first 1MB of this system address space, 0xE0000000 to 0xE00FFFFF, as the Private Peripheral Bus (PPB)

Register in question specifically

Data Watchpoint and Trace (DWT) block 0xE0001000-0xE0001FFF

Section "C1.2.1 General rules applying to debug register access" explicitly state that DWT memory, as a rule of thumb, is privilege access only:

The Private Peripheral Bus (PPB), address range 0xE0000000 to 0xE0100000, supports the following general rules:

  • The region is defined as Strongly-ordered memory
  • Registers are always accessed little-endian
  • Debug registers can only be accessed as a word access
  • A reserved register or bit field has the value UNK/SBZP

Unprivileged access to the PPB causes BusFault errors unless otherwise stated.


Retrieved from "ARMv7-M Architecture Reference Manual" (ARM DDI 0403D)
  • Related