cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Anonymous
Not applicable
3,863 Views

How to get timebase value in ELDK?

Hi,

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!

 

0 Kudos
2 Replies
linnj
Xilinx Employee
Xilinx Employee
3,849 Views
Registered: ‎09-10-2008

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.

 

-- John

0 Kudos
brianhill
Xilinx Employee
Xilinx Employee
3,846 Views
Registered: ‎04-23-2008

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.

 

-Brian

0 Kudos