Docsity

EECS 373 F99: Programmable Counters & Timers, Study notes of Electrical and Electronics Engineering

Toggle sidebar
bg1
EECS 373 F99 Notes 6-1 © 1998, 1999 Steven K. Reinhardt
Programmable Counters & Timers
A programmable counter/timer is a flexible microprocessor
peripheral that counts the edges (voltage transitions) that occur
on an input signal. A counter/timer device has two basic
applications:
1. count events
2. measure time
Why might you want a separate device to perform these
functions?
Generic Counter/Timer
Basic operation:
•Your program initializes register values (typically count
register is initialized to 0).
•On each (e.g., falling) edge of CLK, value in count register
is incremented.
•When count register = limit register, things happen... as
determined by control register settings
This diagram shows an upcounter. Downcounters are similar
(actions occur when the count register reaches 0).
count register
control/status register
limit register
=?
action
CLK
GATE
OUT
INT
n n
pf3
pf4

Partial preview of the text

Download EECS 373 F99: Programmable Counters & Timers and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Programmable Counters & Timers

A programmable counter/timer is a flexible microprocessor peripheral that counts the edges (voltage transitions) that occur on an input signal. A counter/timer device has two basic applications:

  1. count events
  2. measure time

Why might you want a separate device to perform these functions?

Generic Counter/Timer

Basic operation:

  • Your program initializes register values (typically count register is initialized to 0).
  • On each (e.g., falling) edge of CLK, value in count register is incremented.
  • When count register = limit register, things happen... as determined by control register settings This diagram shows an upcounter. Downcounters are similar (actions occur when the count register reaches 0).

count register

control/status register

limit register

=? action

CLK GATE

OUT INT

n n

Programmable Counter/Timer Options

Flexiblity comes because you can program (via the control register(s)) much of the device’s behavior. What happens when count = limit?

  • always set bit in status register
  • may generate interrupt to CPU
  • may reset count to 0
  • may continue counting, or stop
  • may change signal on OUT pin: set, clear, pulse, toggle

May have additional GATE signal that can be programmed to:

  • enable/disable counting of CLK edges
  • reset count to 0 on edge

Counter/Timer Applications

  1. Interval timer
  2. Clock divider
  3. Watchdog timer
  4. Frequency counter

Other MPC823 Timer Registers

  • reference (limit) register TRRx
  • counter register TCNx
  • capture register TCRx
  • event register TERx: bits to indicate
    • “reference event” (limit reached)
    • “capture event” (CTRx valid)