How long is the interval? Microseconds? Seconds? Hours? Years?
As the time gets longer, it gets easier as the accuracy issues tend to go to zero.
For short intervals, I've done things like clear the timer counter (TMRx) internal to the PIC on the first pulse, interupt or poll for the 2nd pulse and at that time read the TMRx value. I'll feed TMRx with the PIC clock so its an accurate count of time.
For long intervals, make a loop of a length suitable (seconds, hours, ect) and check inputs as above, keep the time in a register.




Bookmarks