Measuring microseconds?

I know that you can measure long something takes by measuring the current system time in milliseconds and taking the relative difference but does their exist a way to measure how long something takes in microseconds? It doesn’t seem theoretically impossible with the atmega168’s hardware so I don’t understand why this functionality isn’t available in the arduino libraries.

I guess you could measure the lapse of millis and then multiplying that by 1000 to get microsecs

pulseIn() returns the length of a pulse in microseconds.

micros() is the equivalent of millis() but returns microseconds (with a resolution of 4 microseconds).

I don’t understand why this functionality isn’t available in the arduino libraries

Once you put something in a library you add overhead errors to it. This becomes significant the smaller the time interval you measure. You can use the internal counters and interrupts but you have to roll your own tailored for your specific needs.

I just used the search function and found . I didn’t see this reference page available in “reference” or “extended reference” under the category “time”. Is there another more complete reference guide that I haven’t found yet?

However, when I try to use it in loop(), the compiler returns

In function ‘void loop()’:
error: ‘micros’ was not declared in this scope

Oh, I see that micros was included with arduino, the 13th edition. It seems so surprising the functionality wasn’t already available on the one I had, the 12th edition considering how essential it seems for some processes.

Hmmm…I hadn’t noticed that pop in either!