I would do something like this:Correct hence the codeThough perhaps my explanation was lacking/missingCode:
#define shortpause(a){systick_hw->cvr=0;(void)systick_hw->cvr;while(systick_hw->cvr>a){};}
Code:
systick_hw->csr = 0b101; // set to use processor clock + enable systick_hw->rvr = a; // set RVR with number of cycles (adjusted accordingly) systick_hw->cvr = 0; // clears CVR, then loads from RVR at next clock systick_hw->rvr = 0; // automatically stops the counter at the next wrap, when reaches 0 while(systick_hw->cvr); // waits until CVR becomes 0
Do you know another reliable and simple processor cycle counter ? DWT_CYCCNT ?
The debugger doesn't stop the counter immediately, now on RP2350 it adds 11 more processor clocks to this counter at every break (probably by running the break itself).
Statistics: Posted by gmx — Wed Sep 04, 2024 10:09 pm