m4 MPMC
m4 MPMC
Interfacing chips
MODULE 4
Syllabus:
Programmable Peripheral Input/output port 8255 - Architecture and
modes of operation-Programmable interval timer 8254-Architecture
and modes of operation- DMA controller 8257 Architecture (Just
mention the control word, no need to memorize the control word of
8254 and 8257)
8255 Programmable Peripheral INPUT-OUTPUT
PORT(PPI)
• Also known as parallel input-output port chip
• It is an I/O port chip used for interfacing I/O devices with
microprocessor.
• The Intel’s 8255 is designed for use with Intel’s 8-bit, 16-bit
microprocessors
• It has 24 input/output lines which may be individually
programmed in groups.
• The groups of I/O pins are named as Group A , Group B and
group C upper and Group C lower.
8255 Introduction
• It is developed by Intel
• Used to transfer data under various condition from simple I/O
• It has three 8 bit ports:-
• Port A (PA0-PA7),
• Port B (PB0-PB7),
• Port C(PC0-PC7)
• Port C has Port C upper (PC0-PC7) and Port C lower(PC0-PC3).
• The 24 I/O lines which may be individually programmed into 2
groups:-
• Group A (port A and Port C upper)
• Group B(port B and port C lower )
8255 Pin Diagram
Function of pins:
• Data bus(D0-D7):These are 8-bit bi-directional buses,
connected to 8085 data bus for transferring data.
A1 A0 Select
0 0 PA
0 1 PB
1 0 PC
Control
1 1
reg.
Function of pins:
• RESET: This is used to reset the device. That means
clear control registers.
• PB0-PB7:Similar to PA
• The internal data bus and Outer pins D0-D7 pins are
connected internally.
• PORT A:
• This is a 8-bit buffered I/O latch.
• It can be programmed by mode 0 , mode 1, mode 2 .
• PORT B:
• This is a 8-bit buffer I/O latch.
• It can be programmed by mode 0 and mode 1.
• PORT C:
• This is a 8-bit Unlatched buffer Input and an Output latch.
• It is splitted into two parts.
• It can be programmed by bit set/reset operation.
8255 Operation modes:
• The 8255 can work in 2 modes that are I/O mode and Bit
Set or Reset(BSR) mode
Operation modes:
BIT SET/RESET MODE:
• Only port C(PC0-PC7) can be used to set or reset its individual
port bits.
• The PORT C can be Set or Reset by sending OUT instruction to the
CONTROL registers.
BIT SET/RESET MODE Control Word Register Format:
• This is bit set/reset control word format.
I/O MODE:
• 8255 ports work as programmable i/o ports
• All these modes can be selected by programming control word
register(CWR).
• The control word for both mode is same.
• Bit B7 is used for specifying whether word loaded in to Bit set/reset
mode or Mode definition word.
• B7=1=Mode definition mode.
• B7=0=BSR mode.
MODE 0 (Basic input / Output mode):
-provides simple input/output capability using each of the three ports.
-In this mode , port A, port B and port C is used as individually.
-data can be simply read from and written to input and output port.
Features:
i. In this mode , two 8 bit ports(port A and port B) and two 4 bit ports(port
C upper and port C lower) are available.
ii. Any port can be used as an input or output port.
iii. Outputs are latched , Inputs are buffered
iv. Ports do not have Handshake or interrupt capability.
21
B
MODE 1 :(Strobed I/O mode)
MODE 1 :(Input/output with Hand shake)
• In this mode, input or output is transferred by hand
shaking Signals.
Busy
35
Introduction
• It is always possible to generate accurate time delays using the microprocessor
system by using software loop programs.
• But that will waste the precious time of CPU.
• INTEL introduced the chips 8253/8254 which is a hardware solution for the
problem of generating accurate time delays.
• Programmable interval timer/counter
• When 8253/8254 used as timing and delay generation peripheral, the
microprocessor becomes free from the tasks related to counting process and can
execute programs in memory while timer device may perform counting tasks. This
minimizes software overhead on the microprocessor.
• Has six modes of operation
• It has three independent 16-bit down counters each with a maximum count rate 2.6
MHz
• Operation
- A 16 bit count is loaded on the counter and on command it starts to decrement
- When the count reaches zero it generates a pulse
Features of 8253 / 54
• It can handle inputs from DC to 10 MHz.
• 3 counters can be programmed for either binary or BCD count.
• To operate a counter, a 16-bit count is loaded in its register on
command, it begins to decrement the count until it reaches 0. At the end
of the count, it generates a pulse that can be used to interrupt the CPU.
• It is compatible with almost all microprocessors.
• 8254 has a powerful command called READ BACK command, which
allows the user to check the count value, the programmed mode, the
current mode, and the current status of the counter.
8253/8254 Architecture
Data Bus Buffer
• It is a tri-state, bi-directional, 8-bit buffer, which is used to interface the
internal circuit of 8253/54 to microprocessor system data bus.
Read/Write Logic
• Controls the direction of data buffer upon whether it is a read or write operation.
• It includes 5 signals, i.e. RD, WR, CS, and the address lines A0 & A1.
• In the peripheral I/O mode, the RD and WR signals are connected to IOR and IOW,
respectively. In the memory-mapped I/O mode, these are connected to MEMR and
MEMW.
• Address lines A0 & A1 of the CPU are connected to lines A0 and A1 of the 8253/54, and
CS is tied to a decoded address.
• The control word register and counters are selected according to the signals on lines
A0 & A1.
A1 A0 Result
0 0 Counter 0
0 1 Counter 1
1 0 Counter 2
1 1 Control Word Register
X X No Selection
Control Word Register
• This register is accessed when lines A0 & A1 are at logic 1.
• The control word register contains the information that can be used for writing or
reading the count value into or from the respective count register using OUT and IN
instructions.
• The specialty of 8254 counter is that they can be read on line without disturbing the
clock input to the counter. This facility is called “on the fly” reading of counters.
• It is used to write a command word, which specifies the counter to be used, its
mode, and either a read or write operation. Following table shows the result for
various control inputs.
A1 A0 RD WR CS Result
0 0 1 0 0 Write Counter 0
0 1 1 0 0 Write Counter 1
1 0 1 0 0 Write Counter 2
1 1 1 0 0 Write Control Word
0 0 0 1 0 Read Counter 0
0 1 0 1 0 Read Counter 1
1 0 0 1 0 Read Counter 2
1 1 0 1 0 No operation
X X 1 1 0 No operation
X X X X 1 No operation
Counters
• Each counter consists of a single, 16 bit presettable down counter, which can be
operated in either binary or BCD.
• Its input and output is configured by the selection of modes stored in the control word
register.
• The programmer can read the contents of any of the three counters without disturbing
the actual count in process.
• Counters are programmed by writing a Control Word and then an initial count.
• GATE=1 enables counting, GATE=0 disables counting.
Counter Latch Command
• It is written to the Control Word Register like a Control Word, but two bits
(D5, D4) distinguish this command from a Control Word.
• The selected Counter latches the count at the time the Counter Latch
Command is received.
• The count is held in the latch until it is read by the CPU.
Read-Back Command (Available only for 8254)
• This command allows the user to check the count value, programmed Mode,
and current states of the OUT pin, etc...
• Initially the output is low after the mode is set. The output remains LOW
after the count value is loaded into the counter.
• The process of decrementing the counter continues till the terminal count is
reached, i.e., the count become zero & output goes HIGH and will remain
high until it reloads a new count.
• The GATE signal is high for normal counting. When GATE goes low,
counting is terminated and the current count is latched till the GATE goes
high again.
Mode 1 – Programmable One Shot
• It can be used as a mono stable multi-vibrator(produce time delays within a circuit).
• The gate input is used as a trigger input in this mode.
• The output remains high until the count is loaded and a trigger is applied.
• In Mode 1, after sending the 0-to-1 pulse to GATE, OUT becomes low and stays
low for a duration of count, then becomes high and stays high until the GATE is
triggered again
54
DMA
• DMA stands for Direct Memory Access.
• It is designed by Intel to transfer data at the fastest rate.
• It allows the device to transfer the data directly to/from memory
without any interference of the CPU.
• Using a DMA controller, the device requests the CPU to hold its
data, address and control bus, so the device is free to transfer data
directly to/from the memory.
• The DMA data transfer is initiated only after receiving HLDA signal
from the CPU.
55
DMA Controller
56
DMA Controller 8257
• The DMA I/O technique provides direct access to the memory while the
microprocessor is temporarily disabled.
• The DMA controller temporarily borrows the address bus, data bus and
control bus from the microprocessor and transfers the data directly from
the external devices to a series of memory locations (and vice versa).
57
58
Features of 8257
• It has four channels which can be used over four I/O devices.
• Each channel has 16-bit address and 14-bit counter.
• Each channel can transfer data up to 64kb.
• Each channel can be programmed independently.
• Each channel can perform read transfer, write transfer and verify
transfer operations.
• It generates MARK signal to the peripheral device that 128 bytes
have been transferred.
• Its frequency ranges from 250Hz to 3MHz.
59
Features of 8257
• It execute 3 DMA cycles
1.DMA read 2.DMA write 3.DMA verify.
• It provide AEN signal that can be used to isolate CPU and
other devices from the system bus.
• It is operate in two modes.
1.Master Mode
2.Slave Mode
60
8257 Architecture
61
62
Main Blocks of 8257
• Five main Blocks
1. Data bus buffer
2. Read/Write logic
3. Control logic block
4. Priority resolver
• Resolves the priority of the 4 DMA channels depending upon
whether normal priority or rotating priority is programmed
5. DMA channels
63
Block Description
DATA BUS BUFFER:
• 8 bit, tristate, bi-directional buffer.
• Interfaces internal bus of 8257 with the external system bus under the
control of various control signals.
• Slave mode
• it transfer data between microprocessor and internal data bus.
• Master mode:
• Dataflow to or from the selected peripherals.
64
Block Description
READ/WRITE CONTROL LOGIC:
• It control all internal Read/Write operation.
• Slave mode:
• it accepts address bits and control signal from microprocessor.
• It accepts I/O read and I/O write signals, decodes A0-A3 lines and either either
write the content of databus to the addressed internal register or read content of
selected register depending on depending upon whether IOW or IOR signal is
activated.
• Master mode:
• it generates IOR and IOW signals to control dataflow to or from the selected
peripheral.
Block Description
CONTROL LOGIC BLOCK:
• It contains
1. Control logic
2. Mode set register and
3. Status Register.
• Master mode:
• Controls the sequence of operations and generates the required
control signals like AEN, ADSTB, MEMR,MEWR, TC and MARK along
with the address lines A4-A7.
• It increments 16 bit address and decrement 14 bit counter registers.
• It activate a HRQ(Hold request) signal on DMA channel Request.
• Slave mode - it is disabled.
66
REGISTER ORGANIZATION OF 8257
73
Block Description
STATUS REGISTERS:
76
Block Description
STATUS REGISTERS
77
78
Pin Diagram of 8257
79
Pin Description
CLK:
• It is the input line ,connected with TTL clock generator.
• This signal is ignored in slave mode.
RESET:
• Used to clear mode set registers and status registers
A0-A3:
These are the tristate, buffer, bidirectional address lines.
In slave mode ,these lines are used as address inputs lines
and internally decoded to access the internal registers.
In master mode, these lines are used as address outputs
lines,A0-A3 bits of memory address on the lines.
Pin Description
CS:
• It is active low, Chip select input line.
• In the slave mode, it is used to select the chip.
• In the master mode, it is ignored.
A4-A7:
These are the tristate, buffer, output address lines.
In slave mode ,these lines are used as address outputs
lines.
In master mode, these lines are used as address outputs
lines,A0-A3 bits of memory address on the lines.
Pin Description
READY:
• It is a asynchronous input line.
• In master mode,
• When ready is high it is received the signal.
• When ready is low, it adds wait state between S1 and S3
• In slave mode ,this signal is ignored.
HRQ:
• It is used to receiving the hold request signal from the
output device.
Pin Description
HLDA:
• It is acknowledgment signal from microprocessor.
MEMR:
• It is active low ,tristate ,Buffered control output line.
• In slave mode, it is tristated.
• In master mode ,it activated during DMA read cycle.
MEMW:
• It is active low ,tristate ,Buffered control input line.
• In slave mode, it is tristated.
• In master mode ,it activated during DMA write cycle.
Pin Description
AEN (Address enable):
• It is a control output line.
• In master mode ,it is high
• In slave mode ,it is low
• Used it isolate the system address ,data ,and control
lines.
ADSTB: (Address Strobe)
• It is a control output line.
• Used to split data and address line.
• It is working in master mode only.
• In slave mode it is ignore.
Pin Description
TC (Terminal Count):
• It is a status of output line.
• It is activated in master mode only.
• It is high ,it selected the peripheral.
• It is low ,it free and looking for a new peripheral.
MARK:
• It is a modulo 128 MARK output line.
• It is activated in master mode only.
• It goes high ,after transferring every 128 bytes of data
block.
Pin Description
DRQ0-DRQ3(DMA Request):
• These are the asynchronous peripheral request input
signal.
• The request signals is generated by external peripheral
device.
DACK0-DACK3:
• These are the active low DMA acknowledge output
lines.
• Low level indicate that ,peripheral is selected for giving
the information (DMA cycle).
• In master mode it is used for chip select.
Data Transfer modes
• Single Transfer Mode
In Single Transfer mode the device is programmed
to make one transfer only.
The word count will be decremented and the
address decremented or incremented following each
transfer.
• Block Transfer Mode
In Block Transfer mode the device is activated by
DREQ to continue making transfers during the service
until a TC, or an external End of Process (EOP) is
encountered.
ie, block of data is transferred
87