AnsweredAssumed Answered

Is there a "timer macro"?

Question asked by Francesco Rugiano on Dec 14, 2014
Latest reply on Dec 15, 2014 by Yasuhiko Koumoto


I need a (hopefully) simple timer. BUT I'd prefer not to use an hardware timer.


I explain. I need to measure if a time interval elapsed. My ideal piece of code will be something that gives me the clock ticks since the power on and then divides them by the clock frequency.


In plain old C I'd write


clock_t tmr = clock();

... Operation

int elapsed_ms = (clock()- tmr*1000)*/CLOCKS_PER_SEC;


But... In Kinetis Design Studio (Processor Expert project, so no C++, and no RTOS) the "clock" function returns always 0 and CLOCKS_PER_SEC is equal to 100.

Do you know if there is something I can use? As already stated I'd prefer not to use some hardware timers, because this is just a part of the program and I'd like to limit interferences with other parts.


Thank you




BTW... I'm using a FRDM-K64F board