Go Down

Topic: microseconds (Read 399 times) previous topic - next topic


Is there a way to measure microseconds? I want to find out the interval between certain events (in this case, bytes received by the arduino) and milliseconds is a bit too crude.


There is not a call for measuring microseconds.
You could use delayMicroseconds() and polling to repeatedly wait a while and check to get a rough idea of how long it was.
You could also look at TCNT1 which is a 16 bit register that increments every 4 microseconds in the standard Arduino configuration. It is going to roll over frequently, and you really should block interrupts around reads to it, like this...
Code: [Select]
myVar = TCNT1;

... which assumes you know interrupts were off when you started. (true for normal Arduino code).

Go Up