MPMC Unit-3
MPMC Unit-3
UNIT-3
8086 INTERFACING
UNIT-3
8086 INTERFACING
Semiconductor memories are of two types. viz RAM (Random Access Memory) and ROM
(Read Only Memory). For example, 4Kx 8 or 4k byte memory Contains 4096 locations, where
each location contains 8-bit data and only one of the 4096 locations can be selected at a time.
Once a location is selected all the bits in it are accessible using a group of conductors called 'data
bus.
Thus if the microprocessor has n address lines, then it is able to address at the most N locations
of memory, where 2n = N. However, if out of N locations only P memory locations are to be
interfaced, then the least significant p address lines out of the available n lines can be directly
connected from the microprocessor to the memory chip while the remaining (n-p) higher order
address lines may be used for address decoding (as inputs to the chip selection logic).
The memory address depends upon the hardware circuit used for decoding the chip select (CS).
The output of the decoding circuit is connected with the CS pin of the memory chip.
1. Arrange the available memory chips so as to obtain 16-bit data bus width. The upper 8-bit
bank is called 'odd address memory bank' and the lower 8-bit bank is called even address
memory bank', as described in memory organization.
2. Connect available memory address lines of memory chips with those of the microprocessor
and also connect the memory RD and WR inputs to the corresponding processor control signals.
Connect the 16-bit data bus of the memory bank with that of the microprocessor 8086.
3. The remaining address lines of the microprocessor, BHE and A0 are used for decoding the
required chip select signals for the odd and even memory banks. The CS of memory is derived
from the O/P of the decoding circuit.
In Case of ROM after reset the IP and CS are initialized from address FFFF0. Hence the address
must lie in EEPROM.
PROBLEM
It is required to interface two chips of 32K x 8 ROM and four chips of 32K x 8 RAM with 8086
according to the following map.
ROM 1 and 2 F0000H- FFFFFH, (FFFF0 should lie in ROM)
RAM 1 and 2 D0000H- DFFFFH (if not given you can star anywhere)
RAM 3 and 4 E0000H- EFFFFH
For 32kb 15 address pins are required those are A15-A1
A0 to select even bank
BHE to select odd bank
A19-A16 lines are used to allow A0 and BHE for chip selection
The 8255A is a general purpose programmable I/O device designed to transfer the data from I/O
to interrupt I/O under certain conditions as required. It can be used with almost any
microprocessor.
It consists of three 8-bit bidirectional I/O ports (24I/O lines) which can be configured as per the
requirement.
Control Logic:
The control logic block accepts control bus signals as well as inputs from the address bus, and
issues commands to the individual group control blocks (Group A control and Group B control).
Port B :
This has an 8-bit data I/O latch/ buffer and an 8-bit data input buffer. It can be programmed in
mode 0 and mode 1.
Port C :
This has one 8-bit unlatched input buffer and an 8-bit output latch/buffer. Port C can be splitted
into two parts and each can be used as control signals for ports A and B in the handshake mode.
It can be programmed for bit set/reset operation.
I/O Modes:
Mode 0 : Simple input/output:
In this mode, ports A and B are used as two simple 8-bit I/O ports and Port C as two 4-bit ports.
Each port (or half – port, in case of C) can be programmed to function as simply an input port or
an output port. The input/output features in Mode 0 are as follows :
These handshaking signals are used to tell computer whether printer is ready to accept the data or
not. If printer is ready to accept the data then after sending data on data bus, computer uses
another handshaking signal (STB) to tell printer that valid data is available on the data bus.
The 8255 Pin Diagram mode 1 which supports handshaking has following features.
1. Two ports (A and B) function as 8-bit I/O ports. They, can be configured either as input
or output ports.
2. Each port uses three lines from Port C as handshake signals. The remaining two lines of.
Port C can be used for simple I/O functions.
3. Input and output data are latched.
4. Interrupt logic is supported.
The remaining lines of Port C i.e. PC0-PC2 can be used for simple I/O functions. The Port
B can be programmed in mode 0 or in mode 1. When Port B is programmed in mode 1, PC 0-
PC2 lines of Port C are used as handshaking signals.
The eight possible combinations of the states of bits D 3 – D1 (B2 B1 B0) in the Bit Set-Reset
format (BSR) determine particular bit in PC0 – PC7 being set or reset as per the status of bit D0.
The BSR word can also be used for enabling or disabling interrupt signals generated by
Port C when the 8255 Pin Diagram is programmed for Mode 1 or 2 operations. This is done by
setting or resetting the associated bits of the interrupts. This is described in detail in next section.
The mode definition format for I/O mode is shown in Fig. 14.5. The control words for both,
mode definition and Bit Set –Reset are loaded into the same control register, with bit D7 used for
specifying whether the word loaded into the control register is a mode definition word or Bit Set-
Reset word.
Need of 8251(USART)
8251 universal synchronous asynchronous receiver transmitter (USART) acts as a mediator
between microprocessor and peripheral to transmit serial data into parallel form and vice versa.
1. It takes data serially from peripheral (outside devices) and converts into parallel data.
2. After converting the data into parallel form, it transmits it to the CPU.
3. Similarly, it receives parallel data from microprocessor and converts it into serial form.
4. After converting data into serial form, it transmits it to outside device (peripheral).
Transmit Buffer:
The transmit buffer accepts parallel data from the CPU, adds the appropriate framing
information, serializes it, and transmits it on the TxD pin on the falling edge of TxC.
It has two registers: A buffer register to hold eight bits and an output register to convert eight
bits into a stream of serial bits. The CPU writes a byte in the buffer register, Which is transferred
TxRDY (Transmit Ready ) : This output signal indicates CPU that buffer register is empty and
the USART is ready to accept a data character. It can be used as an interrupt to the system or, for
polled operation, the CPU can ‘check TxRDY using the status read operation. This signal is reset
when a data byte is loaded into the buffer register.
TxE (Transmitter Empty) : This is an output signal. A high on this line indicates that the
output buffer is empty. In the synchronous mode, if the CPU has failed to load a new character in
time, TxE will go high momentarily as SYN characters are loaded into the transmitter to fill the
gap in transmission.
TxC (Transmitter Clock) : This clock controls the rate at which characters are transmitted by
USART. In the synchronous mode TxC is equivalent to the ‘baud rate, and is supplied by the
modem. In asynchronous mode TxC is 1, 16, or 64 times the baud rate. The clock division is
programmable. It can be programmed by writing proper mode word in the mode set register.
Receiver Buffer:
The receiver accepts serial data on the RxD line, converts this serial data to parallel format,
checks for bits or characters that are unique to the communication technique and sends an
“assembled” character to the CPU.
When 8251 is in the asynchronous mode and it is ready to accept a character, it looks for a low
level on the RxD line. When it receives the low level, it assumes that it is a START bit and
enables an internal counter, At a count equivalent to one-half of a bit time, the RxD line is
sampled again. If the line is still low, a valid START bit is detected and the 8251A proceeds to
assemble the character.
After successful reception of a START bit the 8251A receives data, parity and STOP bits, and
then transfers the data on the receiver input register. The data is then transferred into the receiver
buffer register.
In the synchronous mode the receiver simply receives the specified number of data bits and
transfers them to the receiver input register and then to the receiver buffer register.
RxRDY (Receiver Ready) : This is an output signal. It goes high (active), when the USART has
a character in the buffer register and is ready to transfer it to the CPU. This line can be used
either to indicate the status in the status register or to interrupt the CPU. This signal is reset when
a data byte from receiver buffer is read by the CPU.
RxC (Receiver Clock) : This clock controls the rate at which the character is to be received by
USART in the synchronous mode. RxC is equivalent to the baud rate, and is supplied by the
modem. In asynchronous mode RxC is 1, 16, or 64 times the baud rate. The clock division is
programmable. It can be programmed by writing proper mode word in the mode set register.
Modem Control:
The 8251 has a set of control inputs and output’s that can be used to simplify the interface to
almost any modem. It provides control circuitry for the generation of RTS and DTR and the
reception of CTS and DSR. In addition, a general purpose inverted output and a general purpose
input are provided. The output is labeled DTR and the input is labeled DSR. DTR can be
asserted by setting bit 2 of the command instruction; DSR can be sensed as bit 7 of the status
register. When used as a modem control signal DTR indicates that the terminal is ready to
communicate and DSR indicates that it is ready for communication.
1. Mode instruction
2. Command instruction
Mode Instruction:
Fig. 14.38 shows the mode instruction format of 8251.
The instruction can be considered as four 2-bit fields. The first 2-bit field (D1-D0) determines
whether the USART is to operate in the synchronous (00) or asynchronous mode. In the
asynchronous mode, this field determines the division factor for clock to decide the baud rate.
For example, if D1 and D0 are both ones, the RxC and TxC will be divided by 64 to establish the
baud rate.
The second 2-bit field (D3-D2) determines number of data bits in one character. With this 2-bit
field we can set character length from 5-bits to 8 bits.
The third 2-bit field, (D5-D4), controls the parity generation. The parity bit is added to the data
bits only if parity is enabled.
The last field, (D7-D6), has two meanings depending on whether operation is to be in the
synchronous or asynchronous mode. For asynchronous mode, (i.e. D 1D0 ≠ 00), it controls the
number of STOP bits to be transmitted with the character.
In synchronous mode, (i.e. D1D0) = 00) this field controls the synchronizing process. It decides
whether to operate with external synchronization or internal synchronization and whether to
transmit single synchronizing character or two synchronizing characters.
Command Instruction:
It does function such as : Enable Transmit/Receive; Error Reset and modem Control.
Error Definitions:
Parity Error : At the time of transmission of data an even or odd parity bit is inserted in the data
stream. At the receiver end, if parity of the character does not match with the pre-defined parity,
parity error occurs.
Overrun Error : In the receiver section received character is stored in the receiver buffer. The
CPU is supposed to read this character before reception of the next character. But if CPU fails in
reading the character loaded in the receiver buffer, the next the received character replaces the
previous one and the OVERRRUN Error occurs.
Framing Error : If valid stop bit is not detected at the end each character framing error occurs.
All these errors, when occur, set the corrosponding bits in the status register. These error bits are
reset by setting ER bit in the command instruction.
Read/Write Logic:
The RD and WR inputs control the data flow on the data bus when the device is selected by
asserting its chip select (CS) input low.
Control Logic:
This block has an input and an output line. If the 8259A is properly enabled, the interrupt request
will cause the 8259A to assert its INT output pin high. If this pin is connected to the INTR pin of
an 8085/8086 and if the 8085/8086 Interrupt Enable (IE) flag is set, then this high signal will
cause the 8085/8086 to respond INTR as explained earlier.
Priority Resolver:
The priority resolver determines the priorities of the bits set in the IRR. The bit corresponding to
the highest priority interrupt input is set in the ISR during the INTA input.
In such a case, the former is called a master, and the latter are called slaves. The 8259 can be
set up as a master or a slave by the SP/EN pin.
CAS 0 — CAS 2
For a master 8259, the CAS0-CAS2 pins are output pins,
and for slave 8259, these are input pins.
When the 8259 is a master (that is, when it accepts interrupt requests from other 8259s), the
CALL opcode is generated by the Master in response to the first INTA. The vector address must
be released by the slave 8259. The master sends an identification code of three-bits to select one
out of the eight possible slave 8259s on the CAS 0-CAS2 lines. The slave 8259s accept these three
signals as inputs (on their CAS0 – CAS2 pins) and compare the code sent by the master with the
codes assigned to them during initialization. The slave thus selected (which had originally placed
an interrupt request to the master 8259) then puts the address of the interrupt service routine
during the second and third INTA pulses from the CPU.
SP / EN (Slave Program /Enable Buffer):
The SP/EN signal is tied high for the master. However it is grounded for the slave.
The 8259 Programmable Interrupt Controller can be initialized with four ICWs; the first two are
compulsory, and the other two are optional based on the modes being used. These words must be
issued in a given sequence.
After initialization, the 8259A can be set up to operate in various modes by using three different
OCWs; however, they are not necessary to be issued in a specific sequence
A write command following ICW1, with A0 = 1 is interpreted as ICW2. This is used to load the
high order byte of the interrupt vector address of all the interrupts.
Whether to use special fully nested mode or non special fully nested mode.
When the 8259 is not in the Polled mode, after it is set up for. an IRR status read operation, all
Read commands with A0=1 cause the 8259 to send the IRR status word.
1. In I/O data transfer, data is transferred by using microprocessor. The microprocessor will
read data from I/O device and then will write data to memory.
2. In this case, there are two operations for single data transfer. If the data is less then
microprocessor will not waste its time transferring data from I/O to memory or back.
3. But suppose data is huge then the transfer rate from I/O to memory or back will slow
down because of microprocessor intervention.
4. In such case, to speed up the process of transferring the data, I/O should have direct
access to memory.
5. It can have Direct Memory Access (DMA) but under supervision. The device which
supervises data transfer is named as DMA controller.
This block diagram visually represents the major functional components of the 8237
DMA controller and their interactions.
1. Channel Initialization:
o The CPU configures the 8237 by programming its registers, setting parameters like
source/destination memory addresses, transfer size, and transfer mode.
2. DMA Request:
o A peripheral device triggers a DMA transfer by sending a signal to the 8237, typically
when data is ready to be sent or received.
PROGRAM
MOV AL, 80
MOV AL, 88
CALL DELAY
ROR AL, 01
JMP START
GO: DEC BX
JNZ GO
RET
PROGRAM
MOV AL, 80 //
MOV AL, 88
CALL DELAY
ROR AL, 01
JMP START
GO : DEC BX
JNZ GO
LOOP RET
HLT
PROGRAM
MOV AL, 80
OUT DX, AL
INC AL
JB BACK
JMP START
b) Triangular Waveform
MOV AL, 80
MOV AL, 00
DO1: OUT 0FFE0, AL
INC AL
CMP AL, 0FFH
JB DO1 //(AL<FF)
DO: OUT DX, AL
DEC AL
CMP AL, 00H
JA DO //(AL>00)
JMP DO1
MOV AL, 80
OUT 0FFE6, AL
OUT 0FFE0, AL
CALL DELAY
MOV AL, FF
OUT DX, AL
CALL DELAY
JMP AGAIN
RET
INTERFACING OF DAC
MOV AL, 82 H
OUT DX, AL
MOV BL, 00 H
JNC L2
INC BL
L2: DEC CH
JNZ L1
HLT
Interfacing ADC-0808/0809,
• The process of analog to digital conversion is a slow process and the processor has to wait for
the digital data till the conversion is over.
• After the conversion, the ADC sends the End of Conversion (EoC) signal to inform the
processor about it and the result is ready at the output buffer of the ADC. The tasks of issuing
SOC pulse to ADC, reading EOC signal from the ADC and reading the digital output of the
ADC are carried out by the CPU using 8255 I/O ports
• The time taken by the ADC to calculate the equivalent digital data output from the moment of
the start of conversion is called conversion delay of the ADC
• It may range anywhere from a few microseconds, in case of fast ADCs, to even a few hundred
milliseconds in case of slow ADCs.
• Irrespective of the techniques used for conversion, general algorithm for ADC interfacing
contains the following steps
3. Read End of Conversion (EOC) signal to mark the end of conversion process
PROBLEM ON 8251
1. Write the mode control word for a case of asynchronous transmission, with an 8-bit data
format, one stop bit, odd parity and 10000 baud rate. TxC clock is 150 KHz.
ANS: 01 01 11 10