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.

  • \$\begingroup\$ What is the clock source for timer 2? \$\endgroup\$ Apr 29, 2014 at 6:04
  • \$\begingroup\$ a crystal oscillator of 16mhz \$\endgroup\$
    – Rookie91
    Apr 29, 2014 at 6:05

1 Answer 1


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).

  • \$\begingroup\$ A free-running hardware timer should mean you can do this without error due to lost cycles, you just read the timer value and compare it with the next time you need to do the operation. Just beware of the counter wrapping round. \$\endgroup\$
    – John U
    Jun 26, 2014 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.