2.micro Computer IO
2.micro Computer IO
INPUT/OUTPUT
2
Introduction
• The technique of data transfer between a
microcomputer and an external device is called
input/output (I/O).
3
4
5
6
Figure. Basic computer system
7
8
Introduction
❑The characteristics of I/O devices are normally
different from those of a microcomputer like
(speed and word length)
10
11
Introduction
There are three major types of data transfer between the
microprocessor and I/O device.
• Programmed I/O : In programmed I/O the data transfer
is accomplished through an I/O port and controlled by
software.
13
I/O Port (1)
A microcomputer communicates with an
external device via one or more registers called
I/O ports using programmed I/O. I/O ports
are usually of two types.
ii. For the other type, all bits in the port can be
set up as all parallel input or parallel output
bits. 14
I/O Port (2)
▪I/O port is made up of group of 8 pins.
16
I/O Port (4)
Command or data-direction register
▪ Determines the direction of individual pins of ports.
17
I/O Port
(4)
18
A. Programmed I/O
As an example, if an 8-bit data-direction register contains
34H (34 Hex), then which pin’s of the Port is set as Input
and output.
19
A. Programmed I/O
For parallel I/O, there is only one data directional register,
known as the command register for all ports. A particular
bit in the common register configures all bits in the port
as either inputs or outputs. Programmable Peripheral
Interface uses parallel I/O for configuration.
20
A. Programmed I/O
I/O ports are addressed using two techniques.
I. Standard I/O
II. Memory-mapped I/O
21
I. Standard I/O
Two separate address spaces are used – one for memory
location and other for I/O devices.
• The I/O devices are provided dedicated address
space.
• Hence, there are two separate control lines for
memory and I/O transfer.
a. I/O read and I/O write lines for I/O transfer
b.Memory Write and Memory Read for memory
transfer
22
Standard I/O
23
24
I. Standard I/O
Standard I/O or port I/O (called isolated I/O by Intel) uses
an output control pin such as the M/ 𝐼𝑂 pin to
distinguish between I/O and memory.
• M/ 𝐼𝑂pin= High;
The processor outputs a High to indicate that a
memory operation is going on.
▪ M/ 𝐼𝑂 pin = Low;
The processor outputs a Low to indicate that a I/O
operation is going on.
25
Standard I/O
26
Standard I/O
27
II. Memory-mapped I/O
28
II. Memory-mapped I/O
• In memory-mapped I/O, the microprocessor does
not use the M / 𝐼𝑂 control pin. Instead, the
microprocessor uses an unused address pin to
distinguish between memory and I/O.
• In memory mapped I/O, the most significant bit
(msb) of the address can be used to distinguished
between I/O and memory.
Msb=1; I/O port selected
Msb=0; memory location is selected
• This reduces the micro-processor memory by 50%.
29
30
31
Memory mapped
I/O
Printer device
Keyboard device
32
33
Memory mapped I/O
34
Memory mapped
I/O
35
2. Interrupt driven I/O
• Interrupt I/O, an external device can force the
microprocessor to stop executing the current program
temporarily so that it can execute another program
known as an interrupt service routine.
36
2. Interrupt driven I/O
37
2. Interrupt driven I/O
• Interrupts are useful when interfacing I/O devices at
relatively low data transfer rates, such as keyboard
inputs.
38
Time
40
2. Interrupt I/O
There are typically two types of interrupts:
I. External interrupts,
II. Internal interrupts,
41
2. Interrupt I/O
External interrupts can be divided further into two
types: maskable and non-maskable.
42
2. Interrupt I/O
Non-Maskable interrupt cannot be enabled or disabled
by instructions.
44
C. Direct memory access (DMA)
Direct memory access (DMA) is a type of I/O technique
in which data can be transferred between
microcomputer memory and an external device such as
the hard disk, without microprocessor involvement.
45
C. Direct Memory Access (DMA)
46
C. Direct Memory Access
(DMA)
47
48
C. Direct Memory Access
(DMA)
The DMA controller includes several registers :
• The DMA Address Register contains the memory
address to be used in the data transfer.
• BURST mode
• TRANSPARENT Mode
50
C. Direct Memory Access (DMA)
BURST mode
53
C. Direct Memory Access (DMA)
TRANSPARENT Mode
54
• Problem
Transfer of bus control in either direction, from processor
to device or vice-versa, takes 250 ns. One of the IO
device has data transfer rate of 75 KB/sec and employs
DMA.
55
Figure : Sequence diagram showing DMA burst mode 56
1. Burst Mode (Block Mode)
• That is, the DMA interface gains bus mastership prior to the
start of block transfer and maintains control of the bus
until the whole block is transferred.
• Total time = (Transfer of bus control from Processor to DMA)
+ (Time taken to transfer 250 Bytes from DMA to mem)
+ (Finally transferring back bus control from DMA to
Processor)
• Transfer of bus control from Processor to DMA = 250ns
• transferring back bus control from DMA to Processor= 250ns
• Time taken to transfer 250 Bytes from DMA to mem =
256/(75*1024) seconds = 3333333.33 ns
• Total = 250 + 3333333.33 +250
=3333833.33 ns
57
2.Cycle Stealing Mode -
• Let x=Time of Transfer of bus control from Processor to DMA
• Let y=Transfer time of 1 Byte(as Memory is Byte addressable)
from DMA to Mem.
• Let z=Time of Transfer of bus control from DMA to Processor
59
60
Thank You