09-16-2009 02:52 AM
I am using ELDK to develop an embedded application in linux for ML507. I know, the timebase in powerpc440 is a 64 bits counter and I want to get it value. In EDK I used XTime_GetTime(&CounterValue) function but I don't now how to do this in linux! Can you help me? Thanks!
09-16-2009 10:13 AM
I'm no expert here, I have dabbled in the past.
The timers are integrated into the kernel such that you are expected to use the system calls provided in the kernel.
You can use clock_gettime() and then convert the seconds/nanoseconds to something else if needed.
There's probably other ways as I have used the high res timers in the past if you enable them in the kernel. My notes say the time API doesn't change when I used the high res timers, but the resolution was better. Looks like I used getnstimeofday() in my testing.
09-16-2009 10:30 AM
The timebase is a PPC Special Purpose Register (SPR). You'd normally access this with mfspr instructions. This is a privileged instruction and can not be used from user space (your application). That pretty much leaves the APIs previously mentioned. If you need extremely fine grained timers you might want to reconsider whether or not Linux is the appropriate solution to your problem.