开发者

High resolution timer on Coldfire (MCF5328)

开发者 https://www.devze.com 2023-03-13 15:59 出处:网络
I\'ve inherited a embedded project that requires some simple, per-function performance profiling. It consists of a Coldfire (MCF5328) running uClinux (2.6.17.7-uc1).

I've inherited a embedded project that requires some simple, per-function performance profiling. It consists of a Coldfire (MCF5328) running uClinux (2.6.17.7-uc1).

I'm not an expert on either the Coldfire, or uClinux (or Linux for that matter), so excuse my ignorance.

In Windows I would simply use QueryPerformanceCounter to access the x86 high-resolution timer. Record the counter before and after and compare the difference.

I've learned that Linux has a number of variations on QueryPerformanceCounter:

  • clock_gettime/res
  • getnstimeofday
  • ktime_x

Or even access to the Time Stamp Counter via

  • get_cycles

None of these are available on the uClinux build this device is running. So it appears that the OS has no high-resolution timer access.

Does this mean that the Coldfire itself provides no such feature? Or did the开发者_如何学JAVA author of the uClinux port leave them out? Is there something on the hardware that I can use, and how would go about using it?


Given how old your kernel is, you may not have support for high-resolution timers.

If you are writing a kernel driver, the APIs are different. If get_cycles() is stubbed out, it probably means your CPU architecture doesn't support a cycle counter. Since your kernel is very old, do_gettimeofday is probably the best you can do, short of writing a driver to directly query some timer hardware.


I ended up using one of the four DMA Timers on the Coldfire. It was a simple matter to enable the timer as a free-running, non-interrupt generating, counter. This provides a 12.5ns counter (at 80Mhz).

0

精彩评论

暂无评论...
验证码 换一张
取 消