unsigned timer_diff(unsigned start);


The value timer_start() returns, obtained at the start of the period to measure.


Given a value returned by timer_start(), read the hardware timer's current value and return the difference since timer_start() was called. This function provides the difference in number of hardware ticks.

You can use timer_tick2ns() to convert the value returned to nanoseconds.

When you implement this function, keep the following information in mind:

  • Take into account whether the hardware timer counts up or counts down.
  • Assume that timer_start() is called before timer_diff().
  • If timer_start() resets the hardware timer's count value, ensure timer_diff() takes into account the reset action.

For more information and code examples that use this function, see by timer_start().


The number of hardware timer ticks since time_start() was called.