Docsity

Understanding Functionality and Applications of MPC823 Timers: Programmable Counters, Study notes of Electrical and Electronics Engineering

Toggle sidebar
bg1
Programmable Counters and Timers
A programmable counter/timer is a peripheral that counts
edges (voltage transitions) that occur on an input signal:
• counts events
• measures time
• Basic operation
• Application
• MPC823-specific information
Generic Counter/Timer Structure
control/status register
count register limit register
= ?
n n
CLK
GATE
OUT
INT
Basic Operation
• User 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 settings of control/status register.
• Flexible operation, since much of device behavior can be
programmed via the control/status register(s).
• Downcounters: Operation complementary to upcounters.
Programmable Options
Depending on control/status register, when count = limit, one or
more of the following will happen:
• 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
GATE signal can be programmed to
• Enable/disable counting of CLK edges
• Reset count to 0 on edge
pf3

Partial preview of the text

Download Understanding Functionality and Applications of MPC823 Timers: Programmable Counters and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Programmable Counters and Timers

A programmable counter/timer is a peripheral that countsedges (voltage transitions) that occur on an input signal:

• counts events• measures time

• Basic operation• Application• MPC823-specific information

Generic Counter/Timer Structure

control/status register

count register

limit register

n^

n

CLK GATEOUT INT

Basic Operation

  • User program initializes register values. Typically, count registeris initialized to 0.• On each (e.g., falling) edge of CLK, value in count register isincremented.• When count register = limit register, things happen as determinedby settings of control/status register.• Flexible operation, since much of device behavior can beprogrammed via the control/status register(s).• Downcounters: Operation complementary to upcounters.

Programmable Options

Depending on control/status register, when count = limit, one ormore of the following will happen:• 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, toggleGATE signal can be programmed to• Enable/disable counting of CLK edges• Reset count to 0 on edge

Counter/Timer Applications

  • Interval timer• Clock divider• Watchdog timer• Frequency counter

MPC823 Timers

  • See Sec. 16.4 of User’s Manual (part of Communication ProcessorModule)• Four 16-bit counters on chip, two of them (1 and 2) work.• Each has external input (TIN1, TIN2, TIN3, TIN4), which is alsoused for capture mode.• Other inputs: system clock, system clock divided by 16• Only 1 and 2 have output pins (TOUT1* and TOUT2*)
    • Active-low pulse• Toggle
      • Only one gate input (TGATE1*) can be used with 1 or 2
        • Enable count on falling edge, disable count on rising edge• Can also reset counter on falling edge when in restart mode

Timer Block Diagram

Global Configuration Reg

Event Reg Mode Reg Counter Reg Divider^ Reference Reg^ Capture Reg

TimerClockGen CaptureDetection

TOUTx*

TGATE1TINx

System Clock CPM local bus

MPC823 Timer Control Registers

TGCR (Timer Global Configuration Register): 16-bit memory-mapped R/W register that contains configuration parameters usedby all timers.

  • Can pair two to act as a 32-bit timer (1 & 2 and/or 3 & 4)• Power control• Gate mode For each timer x - Mode (control/status) register TMRx• Reference (limit) register TRRx• Counter register TCNx• Capture register TCRx : Latch value of counter at event• Event register TERx : Bits to indicate reference/capture event