How to build a simple and stupid small timer routine

By : Olivier de Broqueville

October 2003

 

DESCRIPTION

This routine is based on an interrupt triggered by TIMER0.  The constants are calculated for a 20 Mhz Xtal.

As this routine was created for a precision-not-sensitive project, the only concern was  to be able to 'stay' fairly accurate on the long run (some minutes per month were acceptable)  With the method of corrections, it was possible to reach  easily a precision of a few seconds per day .  

The constants used here were obviously calculated for my prototype. The numbers can vary with  other componants, due to componants-tolerance.  

The correction method works this way: 

Inconvenients of this method:

Advantage of this method:

Download the TIMER routine here

Tim as also developped a TIMER routine based on the same correction principle (Download Tim's TIMER routine here). It uses TIMER1, counts at 1/100 of a sec and displays days count. You can find details in the 'howto' section here

... but it uses 341 words with printing statements and 133 without ... hehehe...

 

 

Olivier de Broqueville

(Last update : 27/11/03)

 

(*) For people who do not know what 'prescaler' is :  the prescaler is a divider which can devide by a certain factor the number of pulses needed to increment the TIMER counter by one unit.

Example:

Somewhere we can say that the prescaler 'slows down' the TIMER