AnsweredAssumed Answered

To get the algorithm time.

Question asked by VipinDas EK on Mar 30, 2015
Latest reply on Apr 1, 2015 by Yasuhiko Koumoto




I am using a K60 twr board, and i have a delay function like this.

void delay()


  unsigned int i, n;







When i checked the number of cpu cycles (using the systick) it takes,it showed around 3000, which is theoretically correct (optimized code for speed, so 1000nop + 1000 add + 1000 cmp)

Since my cpu is 120Mhz, if i set and reset a gpio before and after calling this delay, i expect

theoritically -> 3000 cpu cycles X 0.0083micro seconds = 25 micro seconds

but, practically (by setting and resetting gpio) i am seeing it as  around 143 micro seconds.


Any idea why this difference? I am really running my core @ 125?, or is my calcultion wrong somewhere?


My systick configurtaio



SYST_CSR = 0x7;


int nStart = SYST_CVR;


int nStop = SYST_CVR;


thanks in advance