I would look at DT's Instants
http://www.picbasic.co.uk/forum/showthread.php?t=3251

The elapsed timer might be what you need, with a little modification...
http://darreltaylor.com/DT_INTS-18/elapsed.html