WebbotLib AVR library
WebbotLib It just does it
Go back to:  Referencetimer.h

TICK_COUNT clockGetus()

Get the current time in µS.
Note that this number will wrap around so a later reading may give a smaller value.
This happens every 0xffffffff or 4,294,967,295 microseconds ie every 4295 seconds or every 72 minutes (approx).
This means that the longest time difference you can sense by subtracting two values is about 72 minutes - this should not be a problem since if you are trying to do that then your program is probably wrong.
Note that, even with wrap around, you can always subtract two values to get a duration (so long as it's less than 72 minutes) ie:
TICK_COUNT start = clockGetus();
... do something ...
TICK_COUNT end = clockGetus();
TICK_COUNT duration = end - start; // the number of uS up to a maximum of 72 minutes
NB if this is called from app_init then it will have unknown results as the clock has not yet been created.

Valid XHTML 1.0 Transitional