Pages: [1]   Go Down
Author Topic: microseconds  (Read 327 times)
0 Members and 1 Guest are viewing this topic.
Stockholm, Sweden
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 203
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
cli();
myVar = TCNT1;
sei();
... which assumes you know interrupts were off when you started. (true for normal Arduino code).
Logged

Pages: [1]   Go Up
Jump to: