Module 3 Memory and IO Interfacing
Module 3 Memory and IO Interfacing
1
8086 Microprocessor
Memory
Processor Memory
▪ Registers inside a microcomputer
▪ Store data and results temporarily
▪ No speed disparity
▪ Cost
Secondary Memory
▪ Storage media comprising of slow
devices such as magnetic tapes and
disks
▪ Hold large data files and programs:
Operating system, compilers,
databases, permanent programs etc. 105
8086 Microprocessor
Memory organization in 8086
8086 : 16-bit
Bank 0 : A0 = 0 Even
addressed memory bank
106
8086 Microprocessor
Memory organization in 8086
108
8086 Microprocessor
Interfacing SRAM and EPROM
110
Interfacing Memory to 8086
Memory Device
7
Memory Chip Size and Numbers
9
RAM ICs
10
RAM ICs
11
Interface 4KB of EPROM with starting address from 0000H and 2KB of RAM
with starting address followed by EPROM. Assume the processor has 16 address
lines.
Step 1-
Total EPROM required = 4KB
Chip Size available = 4KB (assume IC 2732)
No. of chips required = 4KB / 4KB = 1 Chip1
–
Starting address = 0000H
Chip size = 4KB = 4096 * 8 = 1000H
Ending address = 0FFFH
31
Ending address = 17FFH
Memory Map
36
Decoding Logic
EPROM chip size = 4KB RAM
chip size = 2KB
37
Final Implementation
38
Interface 8KB EPROM and 8KB RAM using 4KB devices. Assume the processor
has 16 address lines.
Step 1-
Total EPROM required = 8KB
Chip Size available
= 4KB (assume IC 2732)
No. of chips required
= 8KB / 4KB = 2
Chip size = 4KB = 1000H
Memory Locations from 00000H to 01000-1= 0FFFH
Chip1 – Starting address for 4KB chip1
= 0000H
Ending address for 4KB chip1
= 1000H - 1H = 0FFFH
Chip 2 – Starting address for 4KB chip2
= Previous ending address of 4KB chip1 + 1
= 0FFFH + 1
= 1000H
Ending address for 4KB chip2
= 1000H + 0FFFH = 1FFFH 35
Step 2-
Total RAM required = 8KB
Chip size available
= 4KB (assume IC 6232)
No of chips required
= 8KB / 4KB = 2
Chip 1- Starting address
= Ending address of EPROM + 1
= 1FFFH + 1
= 2000H
Ending address
= 2000H + 0FFFH = 2FFFH
Chip 2 – Starting address
=Previous Ending address + 1
= 2FFFH + 1
= 3000H
Ending address
= 3000H + 0FFFH = 3FFFH 36
Memory Map
41
Decoding Logic
EPROM Chip Size =4KB = RAM Chip Size = 4KB
42
Design a 8086 based system with the following specifications :
1) 8086 working at 10MHz at minimum mode
2) 32KB EPROM using IC 27128
3) 256KB RAM using IC 62512
Step 1-
Total EPROM required = 32KB
Chip Size available
= 16KB (assume IC 27128)
No. of chips required
= 32KB / 16KB = 2
Number of sets required = No. of chips / No. of Banks
=2/2=1
Set 1 – Ending address = FFFFFH
Set size = chip size * 2
= 16KB * 2 = 32KB = 2^15 = 0000 0111 1111 1111 1111 = 07FFF
Starting address = Ending address – Set size
= FFFFFH – 07FFFH
= F8000H
43
Memory
Map
42
Design a 8086 based system with the following specifications :
1) 8086 working in minimum mode at 6MHz
2) 64 KB monitor program memory (EPROM) using IC 27128
3) 128 KB application memory (RAM) using IC 62256
4) 2 16-bit input ports and 2 16-bit output ports in handshaking mode
46
47
Implementation
48
Design a 8086 based system with the following specifications :
1) 8086 working in minimum mode at 8MHz
2) 32 KB monitor program memory (EPROM) using 16KB device
3) 64 KB application memory (SRAM) using 32KB device
49
8086 Microprocessor
The I/O ports or peripherals can be Only IN and OUT instructions can be
treated like memory locations and used for data transfer between I/O
so all instructions related to device and processor
memory can be used for data
transmission between I/O device
and processor
Data can be moved from any Data transfer takes place only
register to ports and vice versa between accumulator and ports
When memory mapping is used for Full memory space can be used for
I/O devices, full memory address addressing memory.
space cannot be used for
addressing memory. Suitable for systems which
require large memory capacity
Useful only for small systems
where memory requirement is less
For accessing the memory mapped For accessing the I/O mapped
devices, the processor executes devices, the processor executes I/O
memory read or write cycle. read or write cycle.
I/O devices
For communication between microprocessor and
outside world
Ports / Buffer IC’s
Microprocessor I/ O devices
(interface circuitry)
Interrupt driven I/ O
I/O device interrupts the
processor and initiate data
transfer
Direct memory access
Data transfer is achieved by 113
bypassing the microprocessor
• Any application of Microprocessor Based system Requires the transfer of data
between external circuitry to the Microprocessor and Microprocessor to the
External circuitry. User can give information (i.e., input) to the Microprocessor
using keyboard and user can see the result or output information from the
Microprocessor with the help of display.
•The port A lines are identified by symbols PA0-PA7 while the port C lines are
Identified as PC4-PC7.
• Similarly, Group B contains an 8-bit port B, containing lines PB0-PB7 and a 4-bit
port C with lower bits PC0- PC3.
• The port C upper and port C lower can be used in combination as an 8-bit port C.
• Both the port C is assigned the same address.
•Thus one may have either three 8-bit I/O ports or two 8-bit and two 4-bit ports
from 8255.
• All of these ports can function independently either as input or as output ports.
• This can be achieved by programming the bits of an internal register of 8255
called as control word register (CWR).
S’ A1 A0 Selection Address
0 0 0 PORT A 80 H
0 0 1 PORT B 81 H
0 1 0 PORT C 82 H
Control
Register
0 1 1 83 H
1 X X No Seletion X
CWR FORMATE
I/O Modes:
Mode 0 (Basic I/O mode): This mode is also called as basic input/output Mode. This mode
provides simple input and output capabilities using each of the three ports. Data can be
simply read from and written to the input and output ports respectively, after appropriate
initialization.
Mode 1
Mode 1: (Strobed input/output mode ) In this mode the handshaking control the
input and output action of the specified port. Port C lines PC0-PC2, provide strobe or
handshake lines for port B.
This group which includes port B and PC0-PC2 is called as group B for Strobed data
input/output. Port C lines PC3-PC5 provides strobe lines for port A.
This group including port A and PC3-PC5 from group A. Thus port C is utilized for
generating handshake signals.
Features -
▪ Two 8-bit ports and two 4-bit ports
▪ Any Port can be input or output
▪ Outputs are latched
▪ Input are not latched
▪ 16 different Input/Output configurations possible
Timing waveform for mode 0 input mode
Functions –
▪ Two ports i.e., port A and B can be use as 8-bit i/o port.
▪ Each port uses three lines of port c as handshake signal and remaining
two signals can be function as i/o port.
▪ Interrupt logic is supported.
▪ Input and Output data are latched.
Mode 2 – (Strobed Bi-directional I/O)
Only group A can be initialized in this mode.
Port A can be used for bidirectional handshake data transfer. This means that
data can be input or output on the same eight lines (PA0 - PA7).
Pins PC3 - PC7 are used as handshake lines for port A.
The remaining pins of port C (PC0 - PC2) can be used as input/output lines if
group B is initialized in mode 0.
In this mode, the 8255 may be used to extend the system bus to a slave
microprocessor.
Program Statement –
Write a program to blink port C bit-2 of 8255. Assume address of
control word register of 8255 as 83H. Use Bit Set / Reset mode.
In the fixed priority, after recognition of any one channel for service, the other channels are
prevented from interfering with that service until it is completed.
If bit 4 of mode set register is logic 0, Operating Modes of 8257 operates in fixed priority
mode.
Rotating Priority Mode :
In rotating priority mode, the priority of the channels has a circular sequence.
In this, channel being serviced gets the lowest priority and the channel next to it gets the
highest priority.
Thus, with rotating priority in a single chip DMA system, any device requesting service is
guaranteed to be recognized after not more than three higher priority services have
occurred.
This prevents any one channel from monopolizing the system.
The rotating priority mode can be set by writing logic ‘1’ in the bit 4 of the mode set
register
Control Logic
In the master mode, Control logic controls the sequence of operation during DMA
cycles (DMA read, DMA write & DMA verify).
It also generates required control signals and memory address to be accessed.
It increments 16-bit address register and decrement count register of corresponding
channel during DMA action.
It is disabled in slave mode.
Mode Set Register
Extended Write Mode :
Microcomputer systems allow use of various types of memory and I/O devices with
different access time.
• If a device can not be accessed within a specific amount of time it
returns a “not ready” indication to the 8257 that causes the 8257 to
insert one or more wait states in its internal sequencing.
• The extended write option provides alternative timing for the I/O
and memory write signals which allows the devices to return an
early READY and prevents the unnecessary occurrence of wait states
in the Operating Modes of 8257.
• It does this by activating MEMW and IOW signals earlier in the DMA
cycle, giving more setup time.
TC STOP Mode :
If the TC stop bit is set, a channel is disabled (i.e. its enable bit is reset) after the terminal
count (TC) output goes high, thus automatically preventing further DMA operation on
that channel.
To enable DMA operation on the channel it is necessary to set enable bit of the
corresponding channel in the mode set register.
If the TC STOP bit is not set, the occurrence of the TC output has no effect on the
channel enable bits.
Auto Load Mode :
Auto load Mode when enabled, permits block chaining operations, without immediate
software intervention between blocks.
In this mode, channel 2 parameters (DMA starting address, terminal count and DMA transfer mode)
are initialized as usual for the first data block.
These parameters are automatically duplicated in the channel 3 registers when channel 2 is initialized.
After the first block of DMA cycles is executed by channel 2 (i.e., after the TC output goes high), the
parameters stored in the channel 3 registers are transferred to channel 2 during an ‘update’ cycle and
next block of DMA cycle is executed.
This repeat block operations can be used in applications such as CRT refreshing.
1.It is a 4-channel Direct Memory Access (DMAC) interface IC which allows data transfer between memory and
up to 4 I/O devices, bypassing CPU.
2.A maximum of 16 KB of data (= 214) can be transferred by this IC sequentially at a time. When a DMA request
comes from a peripheral, the DMAC 8257, via its HRQ (Hold Request) pin, requests the CPU on its HOLD pin.
CPU then acknowledges this request via its HLDA pin which goes to HLDA pin of 8257. After this, DMAC
generates the required MEMR, MEMW, I/OR, I/OW signals.
3.Initialization of the DMAC is done under program control for each channel. The parameters which need to be
initialized for each channel are starting address, number of bytes of data to be transferred, mode of operation, etc.
4. DMAC can be operated in three modes: (a) DMA Read (reading from memory, writing into peripheral), (b)
DMA Write (writing into memory, reading from peripheral), (c) DMA verify.
5. Priority for each of the 4 channels can be set in (a) fixed priority, (b) rotating priority.
6.A Terminal Count Register exists for each of 4 channels. The number of bytes of data to be transferred is
stored in the D13–D0 positions of the 16-bit Terminal Count Register. On completion of data transfer, the
Terminal Count (TC) pin goes high.
7.When the CPU is in control of its buses (address bus, data bus and control bus), it acts as master and DMA
controller acts as the slave. When DMA controller takes control of the buses, it becomes the master and CPU
becomes the slave.
The 8259 can be programmed
through a sequence of simple I/O
operations It accepts two types of
command words.
They are :
(a)Initialization Command Word
(ICW)
(b)Operational Command Word
(OCW)