Professional Documents
Culture Documents
ECEg-M4161 ECE, DU 1
I/O Interface
ECEg-M4161
Issues
Introduction
ECEg-M4161
ECEg-M4161 3
Introduction
I/O Problems
Wide variety of peripherals
o Delivering different amounts of data
o At different speeds
o In different formats
All slower than CPU and RAM
Need I/O modules
ECEg-M4161 4
Introduction
I/O Modules
ECEg-M4161 5
Introduction
External Devices
Human readable
Screen, printer, keyboard
Machine readable
Monitoring and control
Communication
Modem
Network Interface Card (NIC)
ECEg-M4161 6
Introduction
I/O module functions
ECEg-M4161 7
Introduction
I/O steps
CPU checks I/O module device status
I/O module returns status
If ready, CPU requests data transfer
I/O module gets data from device
I/O module transfers data to CPU
ECEg-M4161 8
Introduction
I/O Techniques
Programmed
Interrupt driven
Direct Memory Access (DMA)
ECEg-M4161 9
I/O ports
Two types
ECEg-M4161 10
I/O ports
Memory mapped I/O
Uses instructions that transfers data between
microprocessor & memory
Treated as memory location in the memory map
Portion of memory is used as I/O map
8086 uses M/IO control signal to select b/n
memory and I/O devices.
ECEg-M4161 11
I/O ports
Isolated I/O
I/O locations are isolated from memory system in a separate
address space.
User can expand the memory to its full size
Data transferred between I/O and microprocessor must be
access by IN/OUT instructions
In PC, isolated I/O ports are used for controlling peripheral
device
8-bit port address access devices located on system board.
16-bit port access serial, parallel ports, video & disk drive
ECEg-M4161 12
I/O ports
I/O Addressing
Two addressing modes
1) Immediate port address
- Can only be 1 byte immediate address
- Can only address ports 00h through ffh
2) Port address present in DX
- Can address all ports 0000h through ffffh
- Can only use DX for port addresses
- Can only use AL,AX for port data
ECEg-M4161 13
I/O ports
I/O Instructions
Two I/O instructions:
Transfers information to an I/O device (OUT)
Read information from an I/O device (IN)
ECEg-M4161 14
I/O ports
I/O Instructions…e.g.
ECEg-M4161
I/O Ports
I/O Port
ECEg-M4161 16
I/O Ports
Parallel I/O
Input
Basic input device has a set of tri-state buffers.
ECEg-M4161 17
I/O Ports… a simple I/P ckt.
ECEg-M4161 18
I/O Ports
Parallel I/O
Output
Basic output interface receives data from microprocessor
and must hold it.
Flip-flop latches (buffers) are built into these devices
ECEg-M4161 19
I/O Ports…a simple O/P ckt.
ECEg-M4161 20
PPI (Programmable peripheral interfaces)
Several developed by Intel to ease design burden
Provide a complete I/O interface on a single chip
Examples of common I/O interface chips:
8255A Programmable Peripheral Interface (PPI)
8259 Programmable Interrupt Controller (PIC)
8253/4 Programmable Interval Timer (PIT)
8237 Programmable DMA Controller
IBM PC/XT had these chips on system board
Modern PCs have functionality included in system chipset
ECEg-M4161 21
PPI
8255 - Programmable Peripheral Interface
(Parallel Port Interface)
8 8
Data
Port A
RD 8
Port B
WR
4
RESET
CH
CS
A1
Port C
{ CL
4
A0
ECEg-M4161 22
8086 Microprocessor
Interrupts
ECEg-M4161 23
Interrupt
ECEg-M4161 24
Types of interrupts
Hardware Interrupts
Software Interrupts
256 Interrupts
ECEg-M4161 25
The processor can be interrupted in the following ways
ECEg-M4161 26
Interrupts
Software Interrupt
Hardware Interrupts
(INT n)
ECEg-M4161 27
Hardware Interrupts
ECEg-M4161 28
Interrupts
Hardware
Interrupt
s
Maskable Non-Maskable
Interrupts Interrupts
ECEg-M4161 29
Interrupts
Hardware
Interrupt
s
Maskable Non-Maskable
Interrupts Interrupts
ECEg-M4161 30
Interrupts
Hardware
Interrupts
Maskable Non-Maskable
Interrupts Interrupts
ECEg-M4161 31
Hardware Interrupts
ECEg-M4161 32
Maskable & Non-Maskable Interrupts
ECEg-M4161 33
The interrupts whose request has to be definitely accepted (or cannot be
rejected) by the processor are called non-maskable interrupts. Whenever a
request is made by non-maskable interrupt, the processor has to definitely
accept that request and service that interrupt by suspending its current
program and executing an ISR. In 8086 processor all the hardware
interrupts initiated through INTR pin are maskable by clearing interrupt
flag (IF). The interrupt initiated through NMI pin and all software
interrupts are non-maskable.
ECEg-M4161 34
Maskable & Non-Maskable Interrupts
The programmer
Interrupts cannot control when a
Non-Maskable
Interrupts
Hardware is serviced
Interrupts
The processor has to
stop the main
Maskable Non-Maskable program to execute
Interrupts Interrupts the NMI service
routine
ECEg-M4161 35
Maskable & Non-Maskable Interrupts
Interrupts
ECEg-M4161 36
Non-Maskable Interrupts
ECEg-M4161 37
Software Interrupts
ECEg-M4161 38
Software Interrupt (INT n)
ECEg-M4161 39
8086 INTERRUPTTYPES
256 INTERRUPTS OF 8086 ARE DIVIDED IN TO 3 GROUPS
ECEg-M4161 40
IVT:- 003FF
H
Type FFH Interrupt (Available)
003FC
Available Interrupts
H
(224)
Type 21H Interrupt (Available)
00084H
Type 20H Interrupt (Available)
00080H
Type 1FH Interrupt
0007C
H
(Reserved) Reserved Interrupts
(27)
1 KB
ECEg-M4161 42
General Description of the 8259A
ECEg-M4161 43
8259A Pin-Outs
ECEg-M4161 44
CAS0–CAS2
Thecascade lines are used as outputs from the master to the slaves for
cascading multiple 8259As in a system.
SP/EN
Slave program/enable buffer is a dual-function pin.
when the 8259A is in buffered mode, this output controls the data bus
transceivers in a large microprocessor-based system.
when the 8259A is not in the buffered mode, this pin programs the device as
a master (1) or a slave (0).
ECEg-M4161 45
46 46
ECEg-M4161
Connecting a Single 8259A
Fig. 12–16 shows a single 8259A connected to the microprocessor.
Here the pin SP/EN* is pulled high to indicate that it is a master.
The 8259A requires four wait states for it to function properly with a
16 MHz 80386SX more for some other versions of the Intel
microprocessor family.
ECEg-M4161 47
SP=1 (Master)
PIC is slow, so it
needs torequest
wait states,
particularly with
recent faster
processors
ECEg-M4161 48
49 49
ECEg-M4161
Direct Memory Access (DMA)
50
ECEg-M4161 50
DMA
• Direct Memory Access (DMA) is a method whereby
the memory and I/O space of the microprocessor
can be accessed directly without the intervention of
the microprocessor or a program.
• To request DMA access, the DMAC raises the HOLD
input high.
• The microprocessor responds by floating the 3
buses and raising HLDA high to indicate that a hold
is in effect.
• The DMAC can now use the 3 buses to do DMA
transfers on them- bypassing the processor
ECEg-M4161 51
• During a HOLD, the microprocessor stops
running the program and places its address,
data, and control bus connections at their
High state. This in effect is the same as
removing the microprocessor from its socket!
• While the microprocessor is held, other
devices are free to gain access to its memory
and I/O space and transfer data directly using
them
• Usually this requires the use of a
programmable DMAC chip: (Direct Memory
Access Controller), e.g. the 8237A
ECEg-M4161 52
• HOLD is sampled during instruction execution while
interrupt signals are sampled at the end of instructions
• HOLD takes effect (HLDA generated) in a clock cycle
or two
So, Hold has a higher priority than interrupts
• The only input with a higher priority than HOLD is the
RESET input to the microprocessor.
DMA finished
Device Requests
I/P DMA Transfer
DMA Request
O/P Granted- mP has relinquished
control of the buses
ECEg-M4161 53
DMA Applications
• Wherever large amounts of data need to be
transferred fast between memory and an I/O
peripheral device, e.g.
- Hard disk, CD
- Video memory to refresh display
- Sound cards
- Network cards
- Data acquisition boards
• Also for row address generation by hardware to
refresh large DRAMs fast
ECEg-M4161 54
I/O
Write
Memory
HOLD Read
C
Simultaneously !
Memory address
Generated by fast
Counters on the DMAC
ECEg-M4161 55
DMA Control Signals
• Because during a DMA both memory and an I/O
device may be accessed simultaneously, the DMAC
may need to generate:
- #MRDC and #IOWC (simultaneously) for memory
to I/O device transfers
- #IORC and #MRWC (simultaneously) for I/O device
to memory transfers
ECEg-M4161 56
DMAC Interface
With HLDA
Active
programming operation
16-bit addresses - Data Bus
(during
For address
• Allows the following DMA transfer Counters Programng)
- A8-A15
During DMA
combinations: DMA
- Memory to peripheral Device
- Peripheral to memory
- Peripheral to peripheral
- Memory to memory
• No longer used on the PC in chip form nowadays- its
functionality has been embedded into modern chip set ICs
ECEg-M4161 58
Programming the DMAC
ECEg-M4161 59
DMA Modes: Byte, Burst & Block (3 Bees!)
Bars show
duration
of DMAC
controlling
the buses
Only
for
a
byte
(buffer full)
As long (buffer full)
As Device
Is Ready Block finished?
(filling its buffer)
As long
as needed
to transfer the block
DMAC gets more greedy for bus control
ECEg-M4161 61