Unit 2
Unit 2
1
UNIT 2 Syllabus
• Overview of memory interfacing and I/O interfacing
• Parallel communication interface {8255 PPI}
• Serial communication interface {8251 USART}
• Timer {or counter} – {8253/8254 Timer}
• Keyboard /display controller {8279}
• Interrupt controller {8259}
• DMA controller {8237/8257}
2
Data Transfers
• Synchronous ----- Usually occur when
peripherals are located within the same
computer as the CPU. Close proximity
allows all state bits change at same time
on a common clock.
• Asynchronous ----- Do not require that
the source and destination use the same
system clock.
3
Memory & I/O Interfacing
5
Memory Interfacing
8
Memory Mapped I/O I/O Mapped I/O
9
Parallel communication
interface
INTEL 8255
11
8255 PPI
• The 8255 chip is also called as Programmable
Peripheral Interface.
• The Intel’s 8255 is designed for use with Intel’s 8-
bit, 16-bit and higher capability microprocessors
• The 8255 is a 40 pin IC, designed to perform a
variety of interface functions in a computer
environment.
• It is flexible and economical.
12
PIN DIAGRAM OF 8255
13
Signals of 8255
14
8255 PPI
• It has 24 input/output lines which may be
individually programmed.
• 2 groups of I/O pins are named as
Group A (Port-A & Port C Upper)
Group B (Port-B & Port C Lower)
• 3 ports(each port has 8 bit)
Port A lines are identified by symbols PA0-PA7
Port B lines are identified by symbols PB0-PB7
Port C lines are identified by PC0-PC7 , PC3-PC0
ie: PORT C UPPER(PC7-PC4) , PORT C LOWER(PC3-PC0)
15
D0 - D7: data input/output lines for the device.
All information read from and written to the
8255 occurs via these 8 data lines.
16
• RD : This is the input line driven by the
microprocessor and should be low to
indicate read operation to 8255.
• WR : This is an input line driven by the
microprocessor. A low on this line
indicates write operation.
• A1-A0 : These are the address input lines
and are driven by the microprocessor.
17
Control Logic
• CS signal is the master Chip Select
• A0 and A1 specify one of the two I/O Ports
CS A1 A0 Selected
0 0 0 Port A
0 0 1 Port B
0 1 0 Port C
0 1 1 Control
Register
1 X X 8255 is not
selected
18
Block Diagram of 8255A
19
Block Diagram of 8255 (Architecture)
It has a 40 pins - 4 parts.
1. Data bus buffer
2. Read/Write control logic
3. Group A and Group B controls
4. Port A, B and C
20
1. Data bus buffer
• This is a tristate bidirectional buffer used
to interface the 8255 to system data bus.
• Data is transmitted or received by the
buffer on execution of input or output
instruction by the CPU.
21
2. Read/Write control logic
• This unit accepts control signals ( RD, WR ) and
also inputs from address bus and issues
commands to individual group of control blocks
( Group A, Group B).
• It has the following pins.
CS , RD , WR , RESET , A1 , A0
22
3. Group A and Group B controls
• This block receives control from the CPU
and issues commands to their respective
ports.
Group A - PA and PCU ( PC7 –PC4)
Group B – PB and PCL ( PC3 –PC0)
23
a) Port A: This has an 8 bit latched/buffered
O/P and 8 bit input latch. It can be
programmed in 3 modes – mode 0, mode
1, mode 2.
b) Port B: It can be programmed in mode 0,
mode1
c) Port C : It can be programmed in mode 0
24
CONTROL WORD REGISTER(CWR)
25
Modes of Operation of 8255
Bit Set/Reset(BSR) Mode
Set/Reset bits in Port C
I/O Mode
Mode 0 (Simple input/output)
Mode 1 (Handshake mode)
Mode 2 (Bidirectional Data Transfer)
26
1. BSR Mode
27
Bit/pin of port C
B3 B2 B1
selected
0 0 0 PC0
0 0 1 PC1
0 1 0 PC2
0 1 1 PC3
1 0 0 PC4
1 0 1 PC5
1 1 0 PC6
1 1 1 PC7
33
Example 1
• Consider 8255 programmable peripheral interface is used for the following
situations
• (i) An A/D converter is interfaced to a microprocessor through an 8255. The
conversion is initiated by a signal from the 8255 on Port C. A signal on Port
C causes data to be strobed into Port A.
Ans Mode 1
• (ii) Two computers exchange data using a pair of 8255s. Port A works as a
bidirectional data port supported by appropriate handshaking signals.
Ans Mode 2
Find the appropriate modes of operation of the 8255 for I and II.
Example 2
Find control word
(1) Port A: output with handshake
(2) Port B: input with handshake
(3) Port CL: output (4)Port CU: input
Solution:
1 0 1 0 1 1 1 0 = AEH
35
Example 3
Find the control word for the register arrangement
of the ports of Intel 8255 for mode 0 operation.
Port A: Output, Port B: Output,
Port CU: Output, Port CL: Output
Solution:
1 0 0 0 0 0 0 0 = 80H
The control word register for the above ports of Intel 8255 is
80H.
36
Example 4
Find the control word for the register arrangement
of the ports of Intel 8255 for mode 0 operation.
Port A: Input, Port B: Input,
Port CU: Input, Port CL: Input
Solution:
1 0 0 1 1 0 1 1 = 9BH
The control word register for the above ports of intel
8255 is 9BH.
37
Basics of serial communication
1. Transmitter:
- A parallel-in, serial-out
shift register
2. Receiver:
- A serial-in, parallel-out
Parallel Transfer
shift register.
38
TRANSMITTER
Receiver
39
Serial communication
interface
INTEL 8251 USART
40
UNIVERSAL SYNCHRONOUS
ASYNCHRONOUS RECEIVER
TRANSMITTER (USART)
• Programmable chip designed for synchronous
and asynchronous serial data transmission
• 28 pin DIP
• Converts parallel data into a serial stream of
bits suitable for serial transmission.
• Receives a serial stream of bits and convert it
into parallel data bytes to be read by a
microprocessor.
41
42
BLOCK DIAGRAM
43
Five Sections
– Read/Write Control Logic
• Interfaces the chip with MPU
• Determine the functions according to the control word
• Monitors data flow
– Transmitter
• Converts parallel word received from MPU into serial bits
• Transmits serial bits over TXD line to a peripheral.
– Receiver
• Receives serial bits from peripheral
• Converts serial bits into parallel word
• Transfers the parallel word to the MPU
– Data Bus Buffer- 8 bit Bidirectional bus.
– Modem Controller
• Used to establish data communication modems over
telephone line
44
Input Signals
• CS – Chip Select
When this signal goes low, 8251 is selected by
MPU for communication
• C/D – Control/Data
– When this signal is high, the control register
or status register is addressed
– When it is low, the data buffer is addressed
– Control and Status register is differentiated by
WR and RD signals, respectively
45
• WR – Write
– Writes in the control register or sends outputs to the
data buffer.
– This is connected to I/O Write or Memory Write
• RD – Read
– Either reads a status from status register or accepts
data from the data buffer
– This is connected to either I/O Read or Memory Read
• RESET - Reset
• CLK - Clock
– Connected to system clock
– Necessary for communication with microprocessor.
46
CS C/D RD WR Function
0 1 1 0 MPU writes instruction in the
control register
0 1 0 1 MPU reads status from the status
register
0 0 1 0 MPU outputs the data to the Data
Buffer
0 0 0 1 MPU accepts data from the Data
Buffer
1 X X X USART is not Selected
47
• Control Register
– 16-bit register
– This register can be accessed an output port
when the C/D pin is high
• Status Register
– Checks the ready status of a peripheral
• Data Buffer
48
Transmitter Section
• Accepts parallel data and converts it into serial
data
• Two registers
– Buffer Register
To hold eight bits
– Output Register
Converts eight bits into a stream of serial bits
– Transmits data on TxD pin with appropriate
framing bits(Start and Stop)
49
Signals Associated with Transmitter
Section
• TxD – Transmit Data
– Serial bits are transmitted on this line
• TxC – Transmitter Clock
– Controls the rate at which bits are transmitted
• TxRDY – Transmitter Ready
– Can be used either to interrupt the MPU or
indicate the status
• TxE – Transmitter Empty
– Logic 1 on this line indicate that the output
register is empty
50
Receiver Section
51
Signals Associated with Receiver
Section
• RxD – Receive Data
– Bits are received serially on this line and
converted into parallel byte in the receiver input
• RxC – Receiver Clock
• RxRDY – Receiver Ready
– It goes high when the USART has a character in
the buffer register and is ready to transfer it to the
MPU
52
Signals Associated with Modem
Control
• DSR- Data Set Ready
– Normally used to check if the Data Set is ready when
communicating with a modem (terminal)
• DTR – Data Terminal Ready
– Device is ready to accept data when the 8251 is
communicating with a modem.(modem)
• RTS – Request to send Data
– The receiver is ready to receive a data byte from modem.
(terminal)
• CTS – Clear to Send
--- This is an input terminal for MODEM interface which is
used for controlling a transmit circuit.(modem)
53
SYNDET/BD pin
• This is pin 16 of 8251 and stands for sync. detect (SYNDET)/Break Detect
(BRKDET).
• This pin is used for detection of SYNC characters in synchronous mode and
Break characters in asynchronous mode.
• Synchronous mode: In the synchronous case this pin (SYNDET) can be
used as either input or output pin with the help of control word. When the
system is RESET, the status of this pin is low in the output mode.
• BRKDET: In this mode, this pin acts as an output pin to detect break
characters. If RXD remains low for two consecutive stop bit sequences, this
pin (BRKDET) goes high.
54
Programming 8251
8251 mode register
7 6 5 4 3 2 1 0 Mode register
status
DSR SYNDET FE OE PE TxEMPTY RxRDY TxRDY
register
58
Pin diagram
59
• RD: read signal
• WR: write signal
• CS: chip select signal
• A0, A1: address lines
• Clock :This is the clock input for the counter. The
counter is 16 bits.
• Out :This single output line is the signal that is
the final programmed output of the device.
• Gate :This input can act as a gate for the clock
input line, or it can act as a start pulse
60
61
Control Word Register :This internal register is used to write information
62
8254 Programming
11-63
Mode 0 Interrupt on Terminal Count
CLK
Gate is high
OUT
Will continue
counting
GATE
count of 5 load
Mode 1: One-shot mode Counter will be reloaded
After gate high.
1 2 3 4 5
CLK Gate is
High output
GATE will be high
1 2 3 4 5 1 2 3 4 5 1
CLK
1 2 3 4 1 2 3 4
CLK
OUT
If count is even, 50% duty cycle
count of 6 loaded otherwise OUT is high 1 cycle longer 69
Mode 4 Software Triggered Mode
1 2 3 4 5 6 7 8
CLK
OUT
Trigger with count of 8 In the last counting
Will be stop
(not repeated)
CLK
GATE
72
Keyboard/Display
Controller
INTEL 8279
73
Introduction
INTEL 8279 is specially developed for
interfacing keyboard and display devices to
8085/8086 microprocessor based system
74
Features of 8279
• Simultaneous keyboard and display operations
• Scanned keyboard mode
• Scanned sensor mode
• 8-character keyboard FIFO
• 16-character display
75
Pin Diagram
76
4 sections
• Keyboard section
• Display section
• Scan section
• CPU interface section
77
78
79
Keyboard section
80
• In the 2-key lockout mode, if two keys are
pressed simultaneously, only the first key is
recognized.
• In the N-key rollover mode simultaneous keys are
recognized and their codes are stored in FIFO.
• The keyboard section also have an 8 x 8 FIFO
(First In First Out) RAM.
• The FIFO can store eight key codes in the scan
keyboard mode. The status of the shift key and
control key are also stored along with key code.
The 8279 generate an interrupt signal (IRQ)when
there is an entry in FIFO.
81
Display section
• The display section has eight output lines
divided into two groups A0-A3 and B0-B3.
• The output lines can be used either as a single
group of eight lines or as two groups of four
lines, in conjunction with the scan lines for a
multiplexed display.
• The output lines are connected to the anodes
through driver transistor in case of common
cathode 7-segment LEDs.
84
• The cathodes are connected to scan lines
through driver transistors.
85
Scan section
• The scan section has a scan counter and four scan
lines, SL0 to SL3.
• In decoded scan mode, the output of scan lines will
be similar to a 2-to-4 decoder.
• In encoded scan mode, the output of scan lines will
be binary count, and so an external decoder should
be used to convert the binary count to decoded
output.
• The scan lines are common for keyboard and display.
86
CPU interface section
• The CPU interface section takes care of data
transfer between 8279 and the processor.
• This section has eight bidirectional data lines
DB0 to DB7 for data transfer between 8279
and CPU.
• It requires two internal address: A =0 for
selecting data buffer and A = 1 for selecting
control register of8279.
87
• The control signals WR (low), RD (low), CS
(low) and A0 are used for read/write to 8279.
• It has an interrupt request line IRQ, for
interrupt driven data transfer with processor.
• The 8279 require an internal clock frequency
of 100 kHz. This can be obtained by dividing
the input clock by an internal prescaler.
88
Operational Modes of 8279
There are two modes of operation on 8279 − Input Mode and Output Mode.
Input Mode
This mode deals with the input given by the keyboard and this mode is further classified
into 3 modes.
•Scanned Keyboard Mode − In this mode, the key matrix can be interfaced using
either encoded or decoded scans. In the encoded scan, an 8×8 keyboard or in the
decoded scan, a 4×8 keyboard can be interfaced. The code of key pressed with SHIFT
and CONTROL status is stored into the FIFO RAM.
•Scanned Sensor Matrix − In this mode, a sensor array can be interfaced with the
processor using either encoder or decoder scans. In the encoder scan, 8×8 sensor
matrix or with decoder scan 4×8 sensor matrix can be interfaced.
•Strobed Input − In this mode, when the control line is set to 0, the data on the return
lines is stored in the FIFO byte by byte.
Output Mode
This mode deals with display-related operations. This mode is further classified into two
output modes.
•Display Scan − This mode allows 8/16 character multiplexed displays to be organized
as dual 4-bit/single 8-bit display units.
•Display Entry − This mode allows the data to be entered for display either from the
right side/left side.
When a Key is Pressed
(what happens?)
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 D D K K K
92
SENSOR MATRIX
SENSOR MATRIX
93
B) Programmable clock :
0 0 1 P P P P P
94
c)Read FIFO / Sensor RAM : The format of this command is given
below.
D7 D6 D5 D4 D3 D2 D1 D0
0 1 0 AI X A A A
95
d) Read Display RAM :
This command enables a programmer to read the display RAM data.
D7 D6 D5 D4 D3 D2 D1 D0
0 1 1 AI A A A A
96
d) Write Display RAM :
This command enables a programmer to write the display RAM data.
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 AI A A A A
D7 D6 D5 D4 D3 D2 D1 D0
1 0 1 X IW IW BL BL
D7 D6 D5 D4 D3 D2 D1 D0
1 1 0 CD2 CD1 CD0 CF CA
E- Error mode
X- don’t care
99
Use a keyboard / display controller to interface a 64 key keyboard and an
8 digit seven segment display in right entry mode. Determine the
appropriate commands needed to be given in control word register before
the CPU sends the characters to displayed to the 8279 and inputting data
from return lines into FIFO memory byte by byte
Solution
The format of the command word to select different modes of operation of
8279 is given below with its bit definitions.
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 D D K K K
0 0 0 1 0 1 1 0 = 16
100
INTERRUPT
CONTROLLER
INTEL 8259
101
8259 Programmable Interrupt Controller (PIC)
1. This IC is designed to simplify the implementation of the interrupt interface in the 8088
and 8086 based microcomputer systems.
2. This device is known as a ‘Programmable Interrupt Controller’ or PIC.
3. It is manufactured using the NMOS technology and It is available in 28-pin DIP.
4. 8259A PIC adds eight vectored priority encoded interrupts to the microprocessor.
5. This controller can be expanded without additional hardware to accept up to 64
interrupt request inputs. This expansion required a master 8259A and eight 8259A
slaves.
6. Some of its programmable features are:
· The ability to accept level-triggered or edge-triggered inputs.
· The ability to be easily cascaded to expand from 8 to 64 interrupt-inputs.
· Its ability to be configured to implement a wide variety of priority schemes.
8259A PIC- PIN DIGRAM
8
2
5
9
ASSINGMENT OF SIGNALS FOR 8259:
1. D7- D0 is connected to microprocessor data bus D7-D0 (AD7-AD0).
2. IR7- IR0, Interrupt Request inputs are used to request an interrupt and to connect to a slave
in a system with multiple 8259As.
3. WR - the write input connects to write strobe signal of microprocessor.
4. RD - the read input connects to the IORC signal.
5. INT - the interrupt output connects to the INTR pin on the microprocessor from the master,
and is connected to a master IR pin on a slave.
6. INTA - the interrupt acknowledge is an input that connects to the INTA signal on the system.
In a system with a master and slaves, only the master INTA signal is connected.
7. A0 - this address input selects different command words within the 8259A.
8. CS - chip select enables the 8259A for programming and control.
9. SP/EN - Slave Program/Enable Buffer is a dual-function pin.
SP/EN
❖When the 8259A is in buffered mode, this pin is an
output that controls the data bus transceivers in a
large microprocessor-based system.
❖When the 8259A is not in buffered mode, this pin
programs the device as a master (1) or a slave (0).
CAS2-CAS0
❖ Cascade lines are used as outputs from the master to
the slaves for cascading multiple 8259As in a system.
8259A PIC- BLOCK DIAGRAM
EXPLANATION OF BLOCKS
The Block Diagram consists of 8 blocks which are – Data Bus Buffer, Read/Write
Logic, Cascade Buffer Comparator, Control Logic, Priority Resolver and 3 registers-
ISR, IRR, IMR.
[Link] bus buffer –
This Block is used as a mediator between 8259 and 8086 microprocessor by
acting as a buffer. The data bus buffer consists of 8 bits represented as D0-D7 in
the block diagram. Thus, shows that a maximum of 8 bits data can be transferred
at a time.
2. Read/Write logic –
This block works only when the value of pin CS is low (as this pin is active low).
This block is responsible for the flow of data depending upon the inputs of RD
and WR. These two pins are active low pins used for read and write operations.
3. Control logic –
It is the centre of the microprocessor and controls the functioning of every block.
It has pin INTR which is connected with other microprocessor for taking interrupt
request and pin INT for giving the output. If 8259 is enabled, and the other
microprocessor Interrupt flag is high then this causes the value of the output INT
pin high and in this way 8259 responds to the request made by other
microprocessor.
EXPLANATION OF BLOCKS
[Link] request register (IRR) –
It stores all the interrupt level which are requesting for Interrupt services.
[Link] service register (ISR) –
It stores the interrupt level which are currently being executed.
[Link] mask register (IMR) –
It stores the interrupt level which have to be masked by storing the masking bits
of the interrupt level.
[Link] resolver –
It examines all the three registers and set the priority of interrupts and according
to the priority of the interrupts, interrupt with highest priority is set in ISR
register. Also, it reset the interrupt level which is already been serviced in IRR.
[Link] buffer –
To increase the Interrupt handling capability, we can further cascade more
number of pins by using cascade buffer. So, during increment of interrupt
capability, CSA lines are used to control multiple interrupt structure.
SP/EN (Slave program/Enable buffer) pin is when set to high, works in master
mode else in slave mode. In Non Buffered mode, SP/EN pin is used to specify
whether 8259 work as master or slave and in Buffered mode, SP/EN pin is used as
an output to enable data bus.
A microprocessor accepts external interrupts (Ext INT) through a
Programmable Interrupt Controller as shown in the figure.
Ext INT1 → INT → INTA → ISR (reading data from the device
connected Ext INT1
8237/8257 DMA CONTROLLER
128
Introduction
Direct Memory Access (DMA) is a method of allowing
data to be moved from one location to another in a
computer without intervention from the central
processor (CPU).
It is also a fast way of transferring data within (and
sometimes between) computer.
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).
129
The 8257 DMA controller
130
How DMA Operations are Performed?
Following is the sequence of operations performed by a
DMA −
•Initially, when any device has to send data between the
device and the memory, the device has to send DMA
request (DRQ) to DMA controller.
•The DMA controller sends Hold request (HRQ) to the
CPU and waits for the CPU to assert the HLDA.
•Then the microprocessor tri-states all the data bus,
address bus, and control bus. The CPU leaves the control
over bus and acknowledges the HOLD request through
HLDA signal.
•Now the CPU is in HOLD state and the DMA controller
has to manage the operations over buses between the
CPU, memory, and I/O devices.
DRQ0−DRQ3
8257 pins
These are the four individual channel DMA request inputs, which are used by the peripheral devices for using
DMA services. When the fixed priority mode is selected, then DRQ0 has the highest priority and DRQ3 has the
lowest priority among them.
DACKo − DACK3
These are the active-low DMA acknowledge lines, which updates the requesting peripheral about the status of
their request by the CPU. These lines can also act as strobe lines for the requesting devices.
Do − D7
These are bidirectional, data lines which are used to interface the system bus with the internal data bus of DMA
controller. In the Slave mode, it carries command words to 8257 and status word from 8257. In the master
mode, these lines are used to send higher byte of the generated address to the latch. This address is further
latched using ADSTB signal.
IOR
It is an active-low bidirectional tri-state input line, which is used by the CPU to read internal registers of 8257 in
the Slave mode. In the master mode, it is used to read data from the peripheral devices during a memory write
cycle.
IOW
It is an active low bi-direction tri-state line, which is used to load the contents of the data bus to the 8-bit mode
register or upper/lower byte of a 16-bit DMA address register or terminal count register. In the master mode, it is
used to load the data to the peripheral devices during DMA memory read cycle.
CLK
It is a clock frequency signal which is required for the internal operation of 8257.
RESET
This signal is used to RESET the DMA controller by disabling all the DMA channels.
Ao - A3
These are the four least significant address lines. In the slave mode, they act as an input, which selects one of the
registers to be read or written. In the master mode, they are the four least significant memory address output
lines generated by 8257.
CS
It is an active-low chip select line. In the Slave mode, it enables the read/write operations to/from 8257. In the
master mode, it disables the read/write operations to/from 8257.
A4 - A7
132
These are the higher nibble of the lower byte address generated by DMA in the master mode.
READY
8257 pins
It is an active-high asynchronous input signal, which makes DMA ready by inserting
wait states.
HRQ
This signal is used to receive the hold request signal from the output device. In the slave
mode, it is connected with a DRQ input line 8257. In Master mode, it is connected with
HOLD input of the CPU.
HLDA
It is the hold acknowledgement signal which indicates the DMA controller that the bus
has been granted to the requesting peripheral by the CPU when it is set to 1.
MEMR
It is the low memory read signal, which is used to read the data from the addressed
memory locations during DMA read cycles.
MEMW
It is the active-low three state signal which is used to write the data to the addressed
memory location during DMA write operation.
ADST
This signal is used to convert the higher byte of the memory address generated by the
DMA controller into the latches.
AEN
This signal is used to disable the address bus/data bus.
TC
It stands for ‘Terminal Count’, which indicates the present DMA cycle to the present
peripheral devices.
MARK
The mark will be activated after each 128 cycles or integral multiples of it from the
beginning. It indicates the current DMA cycle is the 128th cycle since the previous
MARK output to the selected peripheral device.
Vcc
It is the power signal which is required for the operation of the circuit. 133
8257 block diagram
134
Features of 8257
Here is a list of some of the prominent 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.
136
DATA BUS BUFFER:
• It contains tristate, 8 bit bi-directional buffer.
• Slave mode, it transfers data between
microprocessor and internal data bus.
• Master mode, outputs A8-A15 bits of memory
address on data lines (Unidirectional).
READ/CONTROL LOGIC:
• It controls all internal Read/Write operation.
• Slave mode, it accepts address bits and control
signal from microprocessor.
• Master mode, it generate address bits and
control signal.
137
Control logic block
1. Control logic
2. Mode set register and
3. Status Register.
CONTROL LOGIC:
• Master mode - It controls the sequence of DMA
operation during all DMA cycles.
• It generates address and control signals.
• It increments 16 bit address and decrement 14 bit
counter registers.
• It activate a HRQ signal on DMA channel Request.
• Slave mode - it is disabled.
138
SLAVE MODE
In this mode the DMA controller is treated as a
peripheral and performs the following steps:
• The microprocessor selects the DMA
controller chip through CS
• Microprocessor initializes the DMAC by giving
the starting address to the 16 bit address
register and number of bytes to be transferred
to the 14 bit count register with the help of
control signals IOR and IOW.
MASTER MODE
After initialization the 8257 enters in master mode and continuously checking
the DMA request from the peripheral and perform the following steps:
• When the I/O device is ready for data transfer, it sends a DMA
request signal to the DMAC through DREQ line.
• The DMA in turn sends a request signal to the µP through the HOLD
line.
• The µP finishes the current machine cycle and releases the system
bus (disconnected from it) and acknowledge the I/O device by
sending a signal through HLDA line.
• After receiving the HLDA signal the DMA controller acknowledge the
I/O device by sending a low signal on DACQ.
• In the mean time the 8257 make use of AEN and ADSTB signals to
take control over buses. After that the DMA transfer begins.
• After every byte is transferred, the address register is incremented
and the count register decremented.
• This continues till the count reaches zero (Terminal Count=1). Now
the DMA transfer is completed.
• At the end of the transfer, the system bus is released by the DMAC by
making the HOLD=0. Then µP takes control over the system buses and
continues its operation
The DMA controller transfers data
in three modes
[Link] Mode: Here, once the DMA controller gains the charge of the
system bus, then it releases the system bus only after completion of data
transfer. Till then the CPU has to wait for the system buses.
[Link] Stealing Mode: In this mode, the DMA controller forces the CPU to
stop its operation and relinquish the control over the bus for a short term to
DMA controller. After the transfer of every byte, the DMA
controller releases the bus and then again requests for the system bus. In
this way, the DMA controller steals the clock cycle for transferring every
byte.
[Link] Mode: Here, the DMA controller takes the charge of system
bus only if the processor does not require the system bus.
Problem
Consider a computer system with DMA support. The DMA
module is transferring one 8-bit character in one CPU cycle from
a device to memory through cycle stealing at regular intervals.
Consider a 2 MHz processor. If 0.5% processor cycles are used for
DMA, calculate the data transfer rate of the device in bits per
second.
Solution
• To complete one cycle at 2 MHz it will take 1/ (2×10^6) seconds. So
the total number of CPU cycles in one second will be 2×10^6.
Now 0.5% of these cycles are taken by DMA to transfer the data.