Teach Yourself PIC Microcontrollers | www.electronicspk.com | 23
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.
Using interrupt in timer operating
If the timer register consists of 8 bits, the largest number that can be written to it is 255 (for 16-bit registers
it is the number 65535). If this number is exceeded, the timer will be automatically reset and counting will
start from zero. This condition is called overflow. If enabled
from within the program, such overflow can
cause interrupt, which gives completely new possibilities. For example, the
state of registers used for
counting seconds, minutes or days can be changed in an interrupt routine. The whole this process (except
interrupt routine) is automatically performed “in the background”, which enables main circuits of the
microcontroller to perform other operations.
Chia sẻ với bạn bè của bạn: