Texas Instruments MSC1210 User Manual
Page 76
Description
8-2
8.1
Description
The MSC1210 comes equipped with three standard timer/counters, all of
which may be controlled, set, read, and configured individually. The
timer/counters have three general functions:
1) Keeping time and/or calculating the amount of time between events
2) Counting the events themselves
3) Generating baud rates for the serial port
The uses of the three timer/counters are distinct, so we will talk about each of
them separately. The first two uses will be discussed in this chapter, whereas
the use of timers for baud rate generation will be discussed in the Chapter 9,
Serial Communication.
8.2
How Does a Timer Count?
The answer to this question is very simple: a timer always counts up. It does
not matter whether the timer is being used as a timer, a counter, or a baud rate
generator. A timer is always incremented by the microcontroller.
8.3
Using Timers to Measure Time
Obviously, one of the primary uses of timers is to measure time. We will discuss
this use of timers first and will subsequently discuss the use of timers to count
events. When a timer is used to measure time, it is also called an interval timer,
because it is measuring the time of the interval between two events.
8.3.1
How Long Does a Timer Take to Count?
Before continuing, it is worth mentioning that when a timer is in interval timer
mode (as opposed to event counter mode) and correctly configured, the timer
will increment by one on each instruction cycle. Therefore, a running timer in
the MSC1210 will be incremented:
33 000 000 / 4 = 8 250 000 times per second
However, to maintain compatibility with existing 8052 code, the default mode
for the MSC1210 timers is to increment by one every three instruction cycles
(i.e., operate as if the timer increments every 12 clocks). Thus, a running timer
can be configured to be incremented:
33 000 000 / 12 = 2 750 000 times per second
Using the first option, which increments the timer every four clocks, allows the
user program to obtain three times higher precision than would be available
by the default mode just explained. Whether the timers are incremented every
four or 12 clocks is controlled by the CKCON SFR.