Specifications

Chapter 2 - Microcontroller PIC16F84
Previous page Table of contents Chapter overview Next page
2.7 Free-run timer TMR0
Timers are usually most complicated parts of a microcontroller, so it is necessary to set aside more
time for their explaining. With their application it is possible to create relations between a real
dimension such as "time" and a variable which represents status of a timer within a microcontroller.
Physically, timer is a register whose value is continually increasing to 255, and then it starts all over
again: 0, 1, 2, 3, 4...255....0,1, 2, 3......etc.
This incrementing is done in the background of everything a microcontroller does. It is up to
programmer to "think up a way" how he will take advantage of this characteristic for his needs. One of
the ways is increasing some variable on each timer overflow. If we know how much time a timer
needs to make one complete round, then multiplying the value of a variable by that time will yield the
total amount of elapsed time.
PIC16F84 has an 8-bit timer. Number of bits determines what value timer counts to before starting to
count from zero again. In the case of an 8-bit timer, that number is 256. A simplified scheme of
relation between a timer and a prescaler is represented on the previous diagram. Prescaler is a name
for the part of a microcontroller which divides oscillator clock before it will reach logic that increases
timer status. Number which divides a clock is defined through first three bits in OPTION register. The
highest divisor is 256. This actually means that only at every 256th clock, timer value would increase
http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_08Poglavlje.htm (1 of 5) [4/2/2003 16:17:58]