Me Mio Interface
Me Mio Interface
What is Interfaced?
• The Intel8085 uses a 16-bit wide address bus for addressing memories and I/O devices
• Using 16-bit wide address bus it can access 216 = 64 K bytes of memory and I/O devices
• The 64K addresses are to be assigned to memories and I/O devices for their addressing
• There are two schemes for the allocation of addresses to memories and input/output devices:
1. Memory mapped I/O scheme
2. I/O mapped memory I/O scheme
• In this scheme, the address assigned to memory locations can also be assigned to a I/O
devices
• The same address may be assigned to a memory location or to an I/O device
• The microprocessor must issue a signal to distinguish whether the address on the address bus
• for a memory location or I/O device
• The Intel8085 issues IO/͞M signal for this purpose
• Two extra instructions IN and OUT are used to address I/O devices
• The IN instruction is used to read data from an input device
• The OUT instruction is used to send data to an output device
• This scheme is suitable for a large system
• An address decoding circuit is employed to select the required I/O device or a memory chip
• If IO/͞M is high, the decoder-2 is activated and the required I/O device is selected
• If IO/͞M is low, the decoder-1 is activated and the required memory chip is selected
• A few MSBs of the address lines are applied to the decoder to select a memory chip or an I/O
device
Interfacing of Memory and I/O Devices
Memory Interfacing
• The address of a memory location or an I/O device is sent out by the microprocessor
• The corresponding memory chip or I/O device is selected by a decoding circuit
• The decoding task can be performed by a decoder, a comparator, a bipolar PROM or PLA
• PLA (Programmed Logic Array), PROM (Programmable Read Only Memory)
• When G1 is low or G2A is high or G2B is high, all output lines become high
• Thus, 74LS138 acts as decoder only when G1 is high, and G2A and G2B are low
• The memory locations for EPROM1lie in the range 0000 to 1FFF
• These are the memory locations for ZONE0 for the memory chip
• Which is connected to the output line Y0 of the decoder
• Similarly, for ZONE1 is 2000 to 3FFFand for ZONE7 is E000 to FFFF
I/O Interfacing
• To solve the problem of speed mismatch between microprocessor and I/O device
• A number of data transfer techniques have been developed
• The data transfer schemes are classified into the following two categories:
1. Programmed data transfer scheme
2. DMA (Direct Memory Access) data transfer scheme
• The CPU sends a hold acknowledge signal to the I/O device to indicate
• It has received the HOLD request and it has released the buses
• DMA transfer scheme is a faster scheme as compared to programmed data transfer scheme
• It is used to transfer data from mass storage devices such as hard disk, optical disk etc.
• DMA data transfer are of the following two types:
1. 1.Burst mode of DMA transfer
2. Cycle stealing technique of DMA data transfer
• In which the I/O device withdraws the DMA request only after all the data bytes have been
transferred
• Called burst mode of data transfer
• By this technique a block of data is transferred
• This technique is employed by magnetic disk drives
• In case of magnetic disks data transfer can not be stopped or slowed down without loss of
data
• Hence, block transfer is must
• In this scheme the microprocessor initiates an I/O device to get ready, and then
• It executes it main program instead of remaining in a program loop to check the status of the
I/O device
• When the I/O device becomes ready to transfer data,
• It sends a high signal to the microprocessor through a special input line called an interrupt
line
• Interrupt driven data transfer is used for slow I/O devices
• It is an efficient technique as compared asynchronous data transfer scheme
Interrupts
• The Intel 8085 has five interrupts inputs namely TRAP, RST7.5, RST6.5, RST5.5 and INTR
• The TRAP has the highest priority, followed by RST7.5, RST6.5 and RST5.5
• The INTR has the lowest priority
• When interrupts are to be used, they are enabled by software using the instruction EI (Enable
Interrupt)
• The instruction EI sets the interrupt enable flip-flop to enable the interrupts
Interrupts Contd…
Interrupts Category
• The interrupt which can be masked-off (i.e., made ineffective) are called maskable interrupts.
• Masking is done by software
• The Intel 8085 has two categories of interrupts: maskable and nonmaskable
• The TRAP is a nonmaskable interrupt, it need not be enabled and disabled, not accessible to
user
• It is used for emergency situation such as power failure and energy shut-off
• RST7.5, RST6.5 and RST5.5 are maskable interrupts
Vectored Interrupt
• The content of the accumulator for instruction SIM to enable RST 7.5, 6.5 and 5.5 are
programmed as follows:
7 6 5 4 3 2 1 0
SOD SOE X R7.5 MSE M7.5 M6.5 M5.5
0 0 0 0 1 0 0 0 = 08
Program:
Mnemonics Comments
EI Enable Interrupts
MVI A, 08 Accumulator bit pattern to enable RST7.5, 6.5 and 5.5
SIM Enable RST 7.5, 6.5, and 5.5
Ex2: Enable RST 6.5 and disable RST 7.5 and 5.5
The content of the accumulator for instruction SIM to enable RST 6.5, and disable RST 6.5 and 5.5
are programmed as:
7 6 5 4 3 2 1 0
SOD SOE X R7.5 MSE M7.5 M6.5 M5.5
0 0 0 1 1 1 0 1 = 1D
• Bits 0 and 2 are set to 1 to mask off (disable) RST7.5, and 5.5
• Bit 3 is set to make Bits 0,1,2 effective
• Bit 4 is set to make 1 to disable RST 7.5, (Bit 1, 0 = enabled)
Program:
Mnemonics Comments
EI Enable Interrupts
MVI A, 1D Accumulator bit pattern to enable RST6.5 and mask-off RST 7.5 and 5.5
SIM Enable RST 6.5 and disable RST 7.5, and 5.5
Pending Interrupts:
• When one interrupt request is being served, other interrupt may occur resulting in a pending
request
• When more than one interrupts occur simultaneously, the interrupt having higher priority is
served
• The interrupt with lower priority remain pending
• An interrupt may occur while other interrupt is being served resulting in a pending interrupt
• The 8085 has an instruction RIM using which we can know the current status of pending
interrupts
• This instruction gives the current status of only maskable interrupts
• To communicate with the outside world microcomputer use peripheral (I/O devices)
• Commonly used peripherals are: A/D converter, D/A converter, CRT, printers, hard disks,
floppy disks etc.
• Peripherals are connected to the microcomputer through electronic circuits, called interfacing
circuit
• The interfacing circuit converts the data available from an input device into compatible
format
• The interface associated with the output device converts the output of the microcomputers
• Into the desired peripheral format
• Intel8085 issues control signals R͞ D, W͞ R for read and write operation of memory and I/O
devices
• It also issues a status signal IO/͞M
• Memory and I/O devices require control signals in the form of:
• MEMR – Memory read
• MEMW – Memory write
• IOR – I/O read
• IOW – I/O write
• These control signals are generated using R͞ D, W͞ R and IO/͞M using logic gates
• To get MEMR, use IO/M̅ ˅ R͞ D: Memory read operation takes place when both are low
• To get MEMW, use IO/͞M ˅ W͞ R: Memory write operation take place when both are low
• I/O read/write operation takes place when IO/͞M is high
• To get IOR and IOW signals, IO/͞M is inverted and then applied to OR gates
• Get IOR using inverted IO/͞M ˅ R͞ D
• Get IOW using inverted IO/͞M ˅ W͞ R
I/O Ports
• If we require one input port and one output port, two units of Intel 8212 will be required
• One of them will be connected in input mode and the other in the output mode
INPUT MODE
OUTPUT MODE
Intel 8255
• The Intel 8255 has the following three modes of operations which are selected by software:
• Mode 0: Simple Input/Output
• Mode 1: Strobed Input/Output
• Mode 2: Bidirectional Port
• The 8255 has two 8-bit ports (Port A and Port B) and two 4-bit ports (Port Cupper and Port
Clower)
• In Mode 0: a port can be operated as a simple input or output port
• Each of the four ports of 8255 can programmed to be either an input or output port
• Mode 1 is strobed input/output mode of operation
• The Port A and Port B both are designed to operate in this mode of operation
• When Port A and Port B are programmed in Mode 1, six pins of port C are used for their
control
• PC0, PC1 and PC2 are used for the control of the Port B which can be used either as input or
output port
• If the Port A is operated as an input port, PC3, PC4 and PC5 are used for its control
• When the Port A is operated as an output port, PC3, PC6 and PC7 are used for its control
• The combination of Mode 1 and Mode 0 operation is also possible
• Ex: when Port A is programmed to operate in Mode 1, the Port B can be operated in Mode 0
• Mode 2 is strobed bidirectional mode of operation
• In this mode, Port A can be programmed to operate as a bidirectional port
• The Mode 2 operation is only for Port A
• When Port A is programmed in Mode 2, the Port B can be used in either Mode 1 or Mode 0
• For Mode 2, PC3 to PC7 are used for the control of Port A
• According to the requirement a port can programmed to act either as an input or an output
port
• For programming the ports of 8255 a control word is formed
• Control word is written into the control word register (CWR) which is within 8255
• No read operation of the CWR is allowed
• The control word bit corresponding to a particular port is set to either 1 or 0
• If a particular port is an input port, the bit is set to 1
• If a particular port is an output port, the bit is set to 0
• Ex1: Make the control word when the ports of Intel 8255 are defined as follows:
• Port A as an input port
• Mode of the Port A – Mode 0
• Port B as an output port
• Mode of the Port B – Mode 0
• Port Cupper as an input port
• Port Clower as an output port
7 6 5 4 3 2 1 0
1 0 0 1 1 0 0 0
• Ex2: Form the control word for the following configuration of the ports of 8255 for Mode 0
• Port A – output
• Port B – output
• Port Cupper – input
• Port Clower – output
7 6 5 4 3 2 1 0
1 0 0 0 1 0 0 0
• Ex3: Make the control word for the following arrangement of the ports of 8255 for Mode 0
• Port A – output
• Port B – output
• Port Cupper – output
• Port Clower – output
7 6 5 4 3 2 1 0
1 0 0 0 0 0 0 0
• Ex4: Frame the control word for the following configuration of the ports of 8255 for
Mode 0
• Port A – input
• Port B – input
• Port Cupper – input
• Port Clower – input
7 6 5 4 3 2 1 0
1 0 0 1 1 0 1 1
• Ex5: Make the control word when the ports of Intel 8255 are defined as follows:
• Port A – input, Mode of the Port A – Mode 1
• Port B – output, Mode of the Port B – Mode 1
• Port Cupper – input
• Port Clower – input/output
7 6 5 4 3 2 1 0
1 0 1 1 1 1 0 x
• Ex6: Frame the control word for the following configuration of the ports of 8255 for Mode 1
• Port A – output
• Port B – output
• Port Cupper – input
7 6 5 4 3 2 1 0
1 0 1 0 1 1 0 x
• The Control Word = AC H if Port Clower = output
• The Cintrol Word = AD H if Port Clower = input
• Ex7: Find control word for the following configuration of the ports of 8255 for Mode 2
• Port A – bidirectional
• Port B – input, Mode of Port B – Mode 0
• Port Clower – output
7 6 5 4 3 2 1 0
1 1 x x x 0 1 0
• Ex8: Write the control word for the following configuration of the ports of 8255 for Mode 2
• Port A – bidirectional
• Port B – output, Mode of Port B – Mode 1
• If assume all undefined bits 0, the control word is C4
• If assume all undefined bits 1, the control word is FD
7 6 5 4 3 2 1 0
1 1 x x x 1 0 x
• Ex9: Determine control word for the following configuration of the ports of 8255
• Port A – output, Mode of Port A – Mode1
• Port B – output, Mode of Port B – Mode 0
• Port Clower – output
• Port Cupper – output
7 6 5 4 3 2 1 0
? ? ? ? ? ? ? ?
• Ex10: Determine control word for the following configuration of the ports of 8255
• Port A – input, Mode of Port A – Mode1
• Port B – output, Mode of Port B – Mode 0
• Port Clower – input
• Port Cupper – output
7 6 5 4 3 2 1 0
? ? ? ? ? ? ? ?
• The programmable interrupt controller is used when several I/O devices transfer data using
interrupt
• They are to be connected to the same interrupt line of the microprocessor
• When the number of I/O devices is less than the number of interrupt lines of the
microprocessor
• Such controllers are not required
Intel 8259
• C͞ S: Chip Select
• W͞ R: Write, A low on this pin enables Intel 8259 to accept command from CPU
• R͞ D: Read, A low on this pin enables Intel 8259 to send various status signals on data bus for
CPU
• D0 – D7: Bidirectional data bus, control, status and interrupt information are transferred via
this bus
• CAS0 – CAS1: Cascade lines
• S͞ P/ E͞ N: Slave program/ Enable buffer, it is related to cascade control
• INT: Interrupt, it is used to interrupt CPU
• INTA: Interrupt acknowledge
• IR0 – IR7: Interrupt requests, I/O devices send interrupt request through these lines
• A0: Address line, it acts in conjunction with R͞ D, W͞ R and C͞ S
• 8 I/O devices can be connected to Intel 8259 through IR0 – IR7 lines
• The interrupt controller functions as overall manager in an interrupt driven system
• If more than one I/O devices send interrupt request at the same time, the interrupt controllers
set the priority
Intel 8251
• C͞ S: Chip Select
• C/D̅ : Control/Data, When it is low data is transmitted on data bus, when high control signal is
transmitted
• W͞ R: Write, when it is low the CPU writes data into Intel 8251
• R͞ D: Read, when it is low the CPU reads data from Intel 8251
• D0 – D7: Bidirectional data bus, control and status information are transferred via this bus
• DSR: Data Set Ready
• DTR: Data Terminal Ready
• RTS: Request to send
• CTS: Clear to send, A low on this pin enables 8251 to transmit serial data
• TxC: Transmitter clock, it governs the rate of data transmission
• TxE: Transmitter empty, TxE goes high when 8251 has no characters to transmit
• TxRDY: Transmitter ready
• RxRDY: Receiver ready
• RxD: Line for receiving data
• TxD: Line for serial data transmission
• RxC: Receiver clock, it governs the rate at which characters are received
• SYNDET/BRKDET: SYNC Detect/Break Detect
• VCC: Operating voltage
• GND: Ground CLK: Clock
• RESET: Indicates that the device is reset
• A high on TxRDY line informs CPU that the transmitter is ready to accept data
• DSR, DTR, RTS and CTS are standard modem control signals
• Modem is a modulating/ demodulating device
Block Diagram of Intel 8251
Intel 8253
• The Intel 8253 is a programmable counter/interval timer
• The 8253 is 24-pin I.C, package and operates at 5 Vdc
• It contains three independent 16-bit counter
• The 8253 is compatible to 8085 microprocessor
• The 8253 operates in the frequency range of d.c. to 2.6 MHz
• The 8253 uses NMOS technology
• The programmer can program 8253 to operate in any one of the 6 operating modes
• It operates under software control
• C͞ S: Chip Select
• W͞ R: Write, when it is low the CPU outputs data in the form mode information or loading of
counters
• R͞ D: Read, when it is low the CPU reads data
• D0 – D7: Bidirectional data bus
• A0, A1: These pins are connected to the address bus, these are used select on of the three
counters
• These are also used the address the control word registers for mode selection
• CLK0, CLK1 and CLK2 are clock for Counter 0, Counter 1, and Counter 2 respectively
• GATE0, GATE1 and GATE2 are gate terminals of Counter 0, Counter 1 and Counter 2
• OUT0, OUT1 and OUT2 are output terminals of Counter 0, Counter 1 and Counter 2
• VCC: Operating voltage
• GND: Ground
• The 8253 contains a data bus buffer, read/write logic and Control Word registers