The number of instructions in your int routine does not matter as long as it doesn't take more then the amount of time to re interupt. I am guessing your int fires every sec (sec=sec+1). So there is plenty of time. What does matter is the time between the interupt firing and the time your routine is actually entered.This number may well be the difference here. What happens is this:
The interupt fires (you think 1 sec has passed or whatever your time base is)
context gets saved
PBP variables get saved (depends on how you set up DT_INT)
and finally you enter interupt routine.
The above can take from 20 - 70 fosc/4 so that could be the out of sync.
Also I don't see where you re-load the timer, Does it just free run and interupt on each rollover? If so the above information prolly IS NOT relevant. As a side note, you could update all the counters within your main code, just set a flag in the interupt so main can see one has occured.




Bookmarks