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

Hi,

 

 

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

void delay()

{

  unsigned int i, n;

  for(i=0;i<1000;i++)

  {

      asm("nop");

  }

}

 

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_RVR = 0xFFFFFFFF;

SYST_CSR = 0x7;

 

int nStart = SYST_CVR;

delay()

int nStop = SYST_CVR;

 

thanks in advance

Outcomes