Due: How can I use CP15 MCR/MRC for instruction profiling ?

On the ARM site,

A coprocessor C15 is mentioned, which supports a cycle (and other) counters.

I want to profile my ‘sketch’. I’m familiar with processor performance counters on other platforms.

To get started, I added a read of the Cycle Counter (to somewhere deep in loop, on receipt of my magic password over serial). The Arduino hangs after printing out half the println that precedes the instruction:

loop() {

// page 3-117
uint32_t cycleCounter = dcc_rd(); // is undefined :frowning:

Serial.print(“CCR value:”);
// Serial.println(cycleCounter);


uint32_t dcc_rd(void)
volatile uint32_t dcc_reg;

do {

// MRC p15, 0, , c15, c12, 1 ;Read Cycle Counter Register
asm volatile (“mrc p15, 0, %0, c15, c12, 1” : “=r” (dcc_reg) :);
} while ((dcc_reg&1) == 0);

asm volatile (“mrc p15, 0, %0, C15, C12, 1” : “=r” (dcc_reg) :);
return dcc_reg;


  • Does the CP15 exist in the Due ARM chip?
  • Are there any examples (googling didn’t help, except for the github links below)
  • Is the above code correct?
  • How can I diagnose why it hung?

My theory is that the instruction needs privileged mode, and maybe I’m not in it (I haven’t set it or anything).

But that’s just a wild guess.



That’s the TRM for the ARM11 microprocessor architecture. Due is a microcontroller that uses a Cortex-M3 core, and it’s quite different. No “co-processor” at all, AFAICT. http://infocenter.arm.com/help/topic/com.arm.doc.100165_0201_00_en/index.html

I’d expect that your program falls into an “unhandled trap” loop when you try to execute the non-existent instruction or non-existent memory location.