21.08.2013 Views

Embedded Systems Design with the Atmel AVR Microcontroller Part II

Embedded Systems Design with the Atmel AVR Microcontroller Part II

Embedded Systems Design with the Atmel AVR Microcontroller Part II

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 6<br />

Timing Subsystem<br />

Objectives: After reading this chapter, <strong>the</strong> reader should be able to<br />

Explain key timing system related terminology.<br />

Compute <strong>the</strong> frequency and <strong>the</strong> period of a periodic signal using a microcontroller.<br />

Describe functional components of a microcontroller timer system.<br />

Describe <strong>the</strong> procedure to capture incoming signal events.<br />

Describe <strong>the</strong> procedure to generate time critical output<br />

signals.<br />

Describe <strong>the</strong> timing related features of <strong>the</strong> <strong>Atmel</strong> ATmega164.<br />

Describe <strong>the</strong> four operating modes of <strong>the</strong> <strong>Atmel</strong> ATmega164 timing system.<br />

Describe <strong>the</strong> register configurations for <strong>the</strong> ATmega164’s Timer 0, Timer 1, and Timer 2.<br />

Program <strong>the</strong> ATmega164 timer system for a variety of applications.<br />

6.1 OVERVIEW<br />

One of <strong>the</strong> most important reasons for using microcontrollers in embedded systems is <strong>the</strong> capabilities<br />

of microcontrollers to perform time related tasks. In a simple application, one can program a<br />

microcontroller system to turn on or turn off an external device at a programmed time. In a more<br />

involved application, we can use a microcontroller to generate complex digital waveforms <strong>with</strong> varying<br />

pulse widths to control <strong>the</strong> speed of a DC motor. In this chapter, we review <strong>the</strong> capabilities of<br />

<strong>the</strong> <strong>Atmel</strong> ATmega164 microcontroller to perform time related functions. We begin <strong>with</strong> a review<br />

of timing related terminology. We <strong>the</strong>n provide an overview of <strong>the</strong> general operation of a timing<br />

system followed by <strong>the</strong> timing system features aboard <strong>the</strong> ATmega164. Next, we present a detailed<br />

discussion of each of its timing channels: Timer 0, Timer 1, and Timer 2 and <strong>the</strong>ir different modes<br />

of operation.<br />

6.2 TIMING RELATED TERMINOLOGY<br />

6.2.1 FREQUENCY<br />

Consider signal x(t) that repeats itself. We call this signal periodic <strong>with</strong> period T, if it satisfies<br />

137

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!