Docsity

Microprocessor Programming - Programmable Timer 8254, Study notes of Microprocessors

Partial preview of the text

Download Microprocessor Programming - Programmable Timer 8254 and more Study notes Microprocessors in PDF only on Docsity!

Delay or Timing Control in MPU System

  • (^) Most common way to produce delay in MPU

system is by implementing delay sub routine using

single loop, multi loop or nested loop.

  • (^) This process suffer from a number of flaws
    • (^) Delay sub routine are not very accurate
    • (^) Involve lot a of calculations for getting accurate delay
    • (^) Keeps MPU pre occupied for entire delay cycle where it

can perform other tasks

  • (^) Loop delays are not very suitable for accurate and

critical timing solutions

8254 Programmable Interval Timer

  • (^) Consists of 3 internal, independent programmable timers (16 bits each).
  • (^) Each can count in binary or BCD.
  • (^) Can be programmed to produce one-shots, act as a square wave generator, a rate generator etc.
  • (^) Can be memory mapped or tied as an isolated I/O device.
  • (^) CPU interface – read/write to 8254’s internal registers to configure mode of operation, load initial values, read current values
  • Programmable Timer
  • 11-
  • Block diagram of

General steps in using 8254

The programming procedure for the 8254 is very

flexible. Only two conventions need to be

remembered:

1) For each Counter, the Control Word must be

written before the initial count is written.

2) The initial count must follow the count format

specified in the Control Word i.e.least significant

byte only, most significant byte only, or least

significant byte and then most significant byte.

Modes of 8254

  • (^) Mode0 :
    • (^) Interrupt on terminal count or event counter
  • (^) Mode1 :
    • (^) Hardware re-triggerable one-shot OR Mono Shot
  • (^) Mode2 :
    • (^) Rate generator or Programmable clock generator
  • (^) Mode3 :
    • (^) Square wave mode or Square wave generator
  • (^) Mode4 :
    • (^) Software triggered strobe or Singe-pulse generator
  • (^) Mode5 :
    • (^) Hardware triggered strobe (re-triggerable) or Hardware-triggered mono shot

Mode 0 Interrupt on terminal count

Mode1 Mono Shot

Mode3 Square wave generator

Mode4 Software triggered strobe

Closer look at any counter

OUT
CLK
GATE
LSB

STATUS

MSB
MSB LSB

LATCH REGISTER

COUNT REGISTER

TIMER/COUNTER CHANNEL

Read Operations

There are three possible methods for reading

the counters:

1. Simple read operation,

2. Counter Latch Command,

3. Read-Back Command.

Counter Latch Command

  • (^) The second method uses the ``Counter Latch Command''.
  • (^) Like a Control Word, this command is written to the Control Word Register, which is selected when A 1 ,A 0 = 11.
  • (^) Also like a Control Word, the SC 0 , SC 1 bits select one of the three Counters, but two other bits, D 5 and D 4 , distinguish this command from a Control Word

Counter Latch Command Contd.

  • (^) The selected Counter's output latch (OL) latches the count at the time the Counter Latch Command is received.
  • (^) This count is held in the latch until it is read by the CPU (or until the Counter is reprogrammed). The count is then unlatched automatically and the OL returns ``following'' the counting element (CE) (count Register).
  • (^) This allows reading the contents of the Counters ``on the fly'' without affecting counting in progress. Multiple Counter Latch Commands may be used to latch more than one Counter. Each latched Counter‘s OL holds its count until it is read. Counter Latch Commands do not affect the programmed Mode of the Counter in any way