Need advice in measuring a pulse which can vary from 100us to 10ms from an ultrasonic sensor. The difficulty is when the second captured timer value is less than the first (overflow occured) in order to compute the pulse width. Should the timer be reset after each edge rather than using a free running counter?
First input capture value = 0xFF00
Second input capture value = 0x0060
Timer clock = 4MHz
TMOD = 39999 (subtract 1 cycle for overflow)