On Mon, Jan 18, 1999 at 06:27:07AM +0100, Gianni wrote: > Unfortunately I haven't considered the necessary time to serve int. and > reload TMR0 . So I lose 10usec. every 8msec. = 4.5sec/h (a poor clock!!) The general solution to this is to add the time constant to TMRO in the interrup t routine, rather than storing the value. E.g. void interrupt tmr0() { TMR0 += -125; } Because at the time of overflow, TMR0 has a value of 0, then however many counts elapse between then and when your interrupt routine runs will be the same as the value of TMR0 at that time, so adding the reload value will automatically compensate for the (variable) interrupt service time. -- Clyde Smith-Stubbs | HI-TECH Software Email: clyde@htsoft.com | Phone Fax WWW: http://www.htsoft.com/ | USA: (408) 490 2885 (408) 490 2885 PGP: finger clyde@htsoft.com | AUS: +61 7 3355 8333 +61 7 3355 8334 --------------------------------------------------------------------------- HI-TECH C: compiling the real world.