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:
// page 3-117
uint32_t cycleCounter = dcc_rd(); // is undefined
volatile uint32_t dcc_reg;
// 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) :);
- 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.