Specifications

mikroElektronika | Free Online Book | PIC Microcontrollers | Introduction: World of Microcontrollers
subtraction T2-T1). If the registers use pulses coming from external source then such a timer is turned into a counter.
This is only a simple explanation of the operation itself.
How does a timer operate?
In practice pulses coming from the quartz oscillator are once per each machine cycle directly or via a prescaler brought to the circuit which
increments the number in the timer register. If one instruction (one machine cycle) lasts for four quartz oscillator periods then, by embedding
quartz with the frequency of 4MHz, this number will be changed a million times per second (each microsecond).
Fig. 0-28 Timer Operation
It is easy to measure short time intervals (up to 256 microseconds) in the way described above because it is the largest number that one register
can contain. This obvious disadvantage may be easily overcome in several ways by using a slower oscillator, registers with more bits, a prescaler
or interrupts. The first two solutions have some weaknesses so it is preferable to use prescalers or interupts.
Using prescaler in timer operating
A prescaler is an electronic device used to reduce a frequency by a pre-determined factor. Meaning that in order to generate one pulse on its
output, it is necessary to bring 1, 2 , 4 or more pulses to its input. One such circuit is built in the microcontroller and its division rate can be
changed from within the program. It is used when it is necessary to measure longer periods of time.
One prescaler is usually shared by timer and watch-dog timer, which means that it cannot be used by both of them simultaneously.
http://www.mikroe.com/en/books/picmcubook/ch0/ (22 of 30)5/3/2009 11:28:39 AM