How can I get current system time with microsecond precision in eCos OS?

545 views Asked by At

I know the default eCos precision is 1 ticks = 10 ms.

And eCos OS provide cyg_current_time();

I can use cyg_current_time divide the tick_per_one_ms to get SystemTime_MS;

(e.g.) GetSystemTime = cyg_current_time() / 10;

How can I get System time with us precision ?

I want to calculate one time interval for us precision.

For example(Want to know how much time that A() cost):

startTime = GetSystemTimeUS();
A();
endTime = GetSystemTimeUS();

printf("A() cost %lu us.",endTime - startTime);

I have tried many method, but it didn't work.

  1. gettimeofday: it seams that eCos implement, but it still ms precision.
  2. get tick: but 1 tick is 10ms. it means that context switching time is ms precision.
  3. timer, clock , etc....

What I mean is that I want to implement a get Current System time function with us precision.

0

There are 0 answers