Microprocessors: From Assembly Language to C Using thePIC18Fxx2

Chapter 13: Timers

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 timer subsystems. This chapter discusses the use of PIC18 timers for time measurement, waveform generation, and pulse width modulation. Example applications include biphase waveform decoding for infrared reception and DC motor control.

13.1 LEARNING OBJECTIVES

After reading this chapter, you will be able to:

  • Discuss the specifics of the Timer0, Timer1, Timer2, and Timer3 subsystems.

  • Use the capture subsystem to perform precise time measurements of external events.

  • Use the PIC18 timer subsystem to decode an infrared receiver's output signal that is either space-width encoded or biphase encoded.

  • Use the pulse width modulation capability of the PIC18 timer subsystem to generate square waves with varying duty cycles and periods, which can be used to control the brightness of an external LED or the speed of a DC motor via pulse width modulation.

  • Implement a real-time clock using a 32.768 kHz clock source and the PIC18 timer subsystem.

13.2 THE TIMERO SUBSYSTEM

The Timer0 subsystem seen in Figure 13.1 can function as either an 8-bit or 16-bit counter/timer as selected by the T08BIT (T0CON[6]) configuration bit. The timer clock source is selected by the T0CS (T0CON[5]) configuration bit; clearing this bit selects the internal instruction cycle clock with frequency of FOSC/4.


Figure 13.1: Timer0 subsystem in 16-bit mode. [1]

Setting T0GS selects the external T0CKI pin as the Timer0 clock source...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Counter and Timer Boards
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.