From Microcontrollers in Practice
6.1 In this Chapter
This chapter contains a description of the timer system of microcontrollers, including the general-purpose timer, the PWM timer, and the watchdog.
6.2 The General Structure and Functions of the Timer System
Timing is essential for the operation of microcontroller systems, either for generating signals with precisely determined duration, or for counting external events. For this reason, the timer subsystem is present in all microcontroller implementations, and covers a wide range of functions including:
Generation of precise time intervals
Measurement of duration of external events
Counting external events.
Most microcontrollers are provided with dedicated timers, or use the general-purpose timer to implement the following additional functions:
Real time clock
Generation of Pulse Width Modulated (PWM) signals
Watchdog for detecting program runaway situations.
Although there are significant variations between different implementations of the general-purpose timer in different microcontrollers, there are many similarities in the principles of operation and the structure of the timer subsystem.
Figure 6.1 shows a general block diagram of the timer system, illustrating the principles of implementation of most MCU timers.
Figure 6.1: General block diagram of the timer subsystem
The central element of the timer subsystem is a counter, TCNT (8 or 16-bits in length), which may be read or (sometimes) written by software. The clock for TCNT is obtained either from the system clock, divided by a programmable prescaler, or an external clock applied to one of the MCU pins. The software control upon the timer is performed by means of the...
Products & Services
Topics of Interest
7.1 In This Chapter This chapter presents several ways in which the microcontrollers interact with analog signals. It contains a description of the analog comparator of AT90S8535, the A/D converter...
Overview Most modern microcontrollers provide a range of timers and the MSP430 is no exception. All devices contain two types of timer and some have five. Each type of timer module works in...
Use of the Timer2 subsystem for periodic interrupt generation was previously discussed in Chapters 10 and 12. However, this only scratches the surface of the capabilities and application of the PIC18...
9.1 Introduction Fast response to asynchronous external events is the most important function of real- time, embedded applications. However, many of these applications must also perform certain...
Microcontrollers keep shrinking, and the newest models are displacing old mechanical methods in a variety of applications. The PIC10F 8-bit Flash microcontroller family includes four devices that...