Delay between timers possible

pictimer

I'm using two timers of Pic18 family controller. The Timer 1 is used for RTCC and Timer 2 is used for counting minutes.

I have used a crystal for RTCC feature, and for Timer 2 I have fixed a count'x' and if count 'x' is equaled, then a minute have been surpassed.

And I would like to make a design such that when Timer 2 counts to 60 mins, do task 1.

My question is: Even though the two timers are of the same controller, will there be any lag (delay in secs) between both timers which would result in any possible delay (in sec or minute)?

Is there any delay possible, I trust there will be delay, but how much is my question. Will it integrate over time?

I would like to know more from people who have used this feature and in course of time if they have experienced any delay or so? And I would welcome any valuable suggestions too.

Best Answer

If both timers are run from the same clock source (a divider doesn't matter) and you do not stop and restart those timers manually, there will be no delay between them since the timers work synchronously (they are bound to a clock). Yet, your clock will probably be skewed over time (but both timers will be skewed by the same amount), so you might be better off with a dedicated RTC.

You could then connect the seconds interrupt of your RTC to an external interrupt input and rely on this source.

I am not quite sure why you would need two timers for this task as this is something which can easily be accomplished by a single timer if you do not care for a few non-accumulating clock cycles delay (which are used in your main loop).