At 21:04 01/25/99 +1000, Clyde Smith-Stubbs wrote: >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 >interrupt >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. isn't it that since every write to timer 0 clears the prescaler, and your addition will write to it (after reading it), you still loose on average half the increment time per write? ge