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...

Copyright Springer Berlin Heidelberg 2005 under license agreement with Books24x7

Products & Services
Counter and Timer Boards
Counter and timer boards are computer cards that perform digital counting and/or timing functions.
IC Timers
IC timers are semiconductor circuits that generate or set timing for electronic circuits.
Microcontrollers (MCU)
Microcontrollers (MCU) are complete computer systems on a chip. They combine an arithmetic logic unit (ALU), memory, timer/counters, serial port, input/output (I/O) ports and a clock oscillator.
Electromechanical Counters
Electromechanical counters are used to detect, totalize, and indicate a sequence of events. They typically accept electric or electronic inputs to operate mechanical outputs such as rotating wheels or knobs. These devices may count UP and/or DOWN, support multiple functions, and provide reset capabilities.
Programmable Automation Controllers (PAC)
Programmable automation controllers (PAC) are compact industrial controllers used in applications such as data acquisition and control, machine vision control, and process control. PACs are functionally similar to programmable logic controllers (PLC), but provide the advanced software features of personal computers (PC).

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...