I am using Arduino Uno board for my project. What I am trying to do is to read the delay between two pulses. A set of pulses are generated using an Arduino Mega board. The delay between each pulse is set to 1 s (1000 ms).
In Arduino Uno I am using the attachinterrupt with the 3rd pin (ISR 1) to detect the rising edge of the pulses. When the first rising edge is detected I am keeping the time using micros() or millis() to a variable (t1) and when the 2nd rising edge is detected again I keep the time using micros() or millis() to another variable (t2).
After that took the difference between (t1 and t2) to get the delay time.
delay = t2 - t1;
Problem is,
When I was using millis() to keep the times for t1 and t2, I got delay values like 1005 ms, 1004 ms, etc. which are almost equal to 1000 ms delay (which is actual delay between the pulses).
When I was using micros() to do the same task the delay values I got are fluctuates a lot and after converting all those values to ms, those are not same as the values I got using millis(). The values I got using micros() are as follows.
658904 us
Can you please help to figure out what is happening in here.