Page 145 - Programming Microcontrollers in C
P. 145

130    Chapter 3  What Are Microcontrollers?

                          counter that counts down from it the value stored in it. When the
                          counter underflows, a flag is set, and an interrupt can be executed.
                              The 15-bit timer is a strictly Motorola name, and it is even
                          simpler than the 8-bit timer. This timer has a 15-bit minimally
                          programmable prescaler. An interrupt can be taken from two
                          locations in this ripple counter.
                              A second class of timer is the 16-bit timer. This timer is often
                          called a general purpose timer. These timers contain a 16-bit counter
                          that is clocked by the system clock. There are two associated
                          subsystems: the first is called an input capture system, and the second
                          is the output compare.
                              The input capture system simply captures the value of the system
                          timer counter when an input occurs. These inputs can set a flag or
                          request an interrupt so the input can be processed either synchronously
                          or asynchronously. The important fact is that the exact time of the
                          input relative to the 16-bit clock is saved when the input occurs.
                          Applications for input capture systems are interpulse period
                          measurements or frequency measurements.
                              The output compare system allows the programmer to specify a
                          time relative to the 16-bit counter when an output is to occur. This
                          time is calculated by adding the time offset value to the current value
                          of the 16-bit counter. This result is stored in the output compare
                          register. When the 16-bit counter counts to the value in the output
                          compare register, the output occurs, a bit is set, and an interrupt can
                          be processed if desired.
                              Input capture and output compare functions are sometimes called
                          high-speed inputs and outputs. The number of input captures and
                          output compare systems vary from as few as one each to as many as
                          16 programmable timers, each of which can be either input capture
                          or output compare.
                              There is another style of timer subsystem that is used on high-end
                          microcontrollers. This system is called the timer processor unit (TPU).
                          In most conventional computers, the contents of a memory location
                          are called an operand, and the processor has built-in operators that
                          operate on the operands. A TPU is also a computer, but rather than
                          using memory location contents as operands, time is the main operand
                          used by the TPU. Most TPUs contain many complex systems to
                          implement their operation. The TPU of the M68300 family and the
                          M68HC16 family contains sixteen registers, each of which can be
   140   141   142   143   144   145   146   147   148   149   150