MPMC Module-2 Interfacings and 8086 at 2024-25 Odd Sem
MPMC Module-2 Interfacings and 8086 at 2024-25 Odd Sem
Assistant Professor
Dept. of ETC, IIIT-Bhubaneswar.
Syllabus : Module-2
Interfacing: Programmable peripheral interface 8255, ADC, DAC, Relay and
Stepper Motor interfacing.
2
By T.VenkataSridhar, ETC
Interfacing Devices
8255 PPI Programmable Peripheral Interface
3
8279 KDC Keyboard and Display Controller
By T.VenkataSridhar, ETC
8255- PPI
Features:
It is a programmable device.
T T L compatible.
4 By T.VenkataSridhar, ETC
Block Diagram
5 By T.VenkataSridhar, ETC
Pin Diagram
6 By T.VenkataSridhar, ETC
Function of pins:
Data bus(D -D ):These are 8-bit bi-directional
0 7
buses, connected to 8085 data bus for
transferring data.
A1 A0 Select
0 0 PA
0 1 PB
1 0 PC
8 By T.VenkataSridhar, ETC
RESET: This is used to reset the device. That
means clear control registers.
PB -PB :Similar to PA
0 7
DATA BUS
STB
Computer Printer
ACK
Busy
11 By T.VenkataSridhar, ETC
MODE 2: Strobe bi-directional I/O data transfer:
This mode allows bidirectional data transfer over a single 8-bit data bus using
handshake signals.
This feature is possible only Group A
Port A is working as 8-biy bidirectional.
PC3-PC7 is used for handshaking purpose.
The data is sent by CPU through this port , when the peripheral request it.
Mode 0
Basic I/O
Mode 1
Strobe I/O
Mode 2
Bi-Dir Bus
12 By T.VenkataSridhar, ETC
CONTROL WORD FORMATS:
1. In the INPUT mode , When RESET is High all 24 pins (3-ports)
be a input mode.
2. i.e all flip flops are cleared, and the interrupts are rest.
3. This condition is maintained even after RESET goes low.
4. This can be avoided by writing single control word to the
control registers , when required
13
CWR FOR I/O MODE:
14 By T.VenkataSridhar, ETC
Strobed mode
Or
Or
8085(2)
8085(1)
15 By T.VenkataSridhar, ETC
8255 Interfacings
Or
8085
System
16 By T.VenkataSridhar, ETC
8255 Interfacings contd..
17 By T.VenkataSridhar, ETC
8255 Interfacings contd..
18 By T.VenkataSridhar, ETC
Relays understanding
A relay is an electrically operated switch. Many relays use
an electromagnet to mechanically operate a switch, but other operating
principles are also used, such as solid-state relays. Relays are used
where it is necessary to control a circuit by a separate low-power
signal, or where several circuits must be controlled by one signal.
19 By T.VenkataSridhar, ETC
Interfacing a relay with 8085 via 8255 to run High load device
Execute a
Program to
enable or
energise
the coil.
20 By T.VenkataSridhar, ETC
Stepper Motor Interfacing
21 By T.VenkataSridhar, ETC
22 By T.VenkataSridhar, ETC
Interfacing Analog to Digital Data
Converters
• In most of the cases, the PIO 8255 is used for interfacing the
analog to digital converters with microprocessor.
• The analog to digital converters is treaded as an input device by
the microprocessor / controller , that sends an initialising signal to
the ADC to start the analogy to digital data conversation process.
The start of conversation signal is a pulse of a specific duration.
• The process of analog to digital conversion is a slow process, and
the microprocessor has to wait for the digital data till the
conversion is over. After the conversion is over, the ADC sends end
of conversion EOC signal to inform the microprocessor that the
conversion is over and the result is ready at the output buffer of the
ADC. These tasks of issuing an SOC pulse to ADC, reading EOC
signal from the ADC and reading the digital output of the ADC are
23
carried out by the CPU using 8255 I/O ports. By T.VenkataSridhar, ETC
• The time taken by the ADC from the active edge of SOC pulse till
the active edge of EOC signal is called as the conversion delay of
the ADC.
• It may range any where from a few microseconds in case of fast
ADC to even a few hundred milliseconds in case of slow ADCs.
• The available ADC in the market use different conversion
techniques for conversion of analog signal to digitals. Successive
approximation techniques and dual slope integration techniques are
the most popular techniques used in the integrated ADC chip.
Or 8085
28 By T.VenkataSridhar, ETC
Interfacing Digital To Analog Converters
• INTERFACING DIGITAL TO ANALOG CONVERTERS: The
digital to analog converters convert binary number into their
equivalent voltages. The DAC find applications in areas like
digitally controlled gains, motors speed controls, programmable
gain amplifiers etc.
31 By T.VenkataSridhar, ETC
8251- USART
32 By T.VenkataSridhar, ETC
33 By T.VenkataSridhar, ETC
34 By T.VenkataSridhar, ETC
35 By T.VenkataSridhar, ETC
RS-232C
A widely accepted interface standard originally developed to foster data
communication on public telephone network through a modem
(modulatordemodulator). This has been adapted to the communication of
terminals (PCs) directly to computer.
This device also receives serial data from the outside and
transmits parallel data to the CPU after conversion.
37 By T.VenkataSridhar, ETC
Block diagram of 8251
38 By T.VenkataSridhar, ETC
39 By T.VenkataSridhar M.Tech,MIETE
40 By T.VenkataSridhar, ETC
41 By T.VenkataSridhar, ETC
Control Registers: MI-Mode Instruction Reg.
CI-Command “ “.
Status Reg.
42 By T.VenkataSridhar, ETC
43 By T.VenkataSridhar, ETC
44 By T.VenkataSridhar, ETC
45 By T.VenkataSridhar, ETC
Fig: Interfacing with 8085.
46 By T.VenkataSridhar M.Tech,MIETE
47 By T.VenkataSridhar M.Tech,MIETE
8086
48 By T.VenkataSridhar, ETC
8259 – Programmable Interrupt Controller
* Topics beyond syllabus starts.. SKIP
50 By T.VenkataSridhar, ETC
51
Initialization Command Word (ICW1, ICW2)
52 By T.VenkataSridhar, ETC
ICW 3, ICW4
53 By T.VenkataSridhar, ETC
54 By T.VenkataSridhar, ETC
Interfacing with Processor - 8085
55 By T.VenkataSridhar, ETC
Interfacing with - 8086
56 By T.VenkataSridhar, ETC
8257 – Direct Memory Access Controller
57 By T.VenkataSridhar, ETC
58 By T.VenkataSridhar M.Tech,MIETE
By T.VenkataSridhar, ETC
Pin-diagram of DMA-8237
59 By T.VenkataSridhar M.Tech,MIETE
By T.VenkataSridhar, ETC
Control Registers of DMA-8237
CAR (Current Address Register): holds the 16-bit memory address
used for the DMA transfer (one for each channel), either
incremented or decremented during the operation
CWCR (Current Word Count Register): Programs a channel for the
number of bytes (up to 64K) transferred during a DMA operation
BA (Base Address) and WC (Word Count): Used when auto-
initialization is selected for a channel, to reload the CAR and CWCR
when DMA is complete.
CR (Command Register): Programs the operation of the controller
60
By T.VenkataSridhar, ETC
MR (Mode Register): Programs the mode of
operation for a channel (one for each channel).
62 By T.VenkataSridhar, ETC
Programming the 8237
First program the address and count registers first:
1. Clear the F/L flip-flop with a clear F/L command
2. Disable the channel
3. Program the LSB and then MSB of the address
4. Program the LSB and then MSB of the count
select the mode of operation
Enable channel
Example(with 8086)
Design the 8237/57 decoding circuit and the 8237/57
address line connections so that the 8237/57 is in the
address range 70h-7Fh.
Write a program that starts a block memory-to-memory
DMA transfer from memory locations 10000H-13FFFH to
63
14000H-17FFFH using channel 0 as source and channel
By T.VenkataSridhar, ETC
8237 Programming Example
64 By T.VenkataSridhar, ETC
EXAMPLE (CONTINUED)
MOV AL, 4;START DMA TRANSFER BY SETTING REQUEST BIT FOR CHANNEL 2
OUT REQ, AL
65 By T.VenkataSridhar, ETC
66
8253 - Programmable Interval Timer
PIT
(programmable
Interval Timer),
used to bring
down the
frequency
Three
to the
counters
desired level.
inside
8253/8254. Each
works
independently
and is
programmed
separately to
divide the input
There are 4by
frequency porta
address
number needed
from 1
for a
to 65536. single
8253/8254,
given by A0, A1,
67
and CS. By T.VenkataSridhar, ETC
68 By T.VenkataSridhar, ETC
69 By T.VenkataSridhar, ETC
70 By T.VenkataSridhar, ETC
71 By T.VenkataSridhar, ETC
72 By T.VenkataSridhar, ETC
8279 – Keyboard & Display Controller
Intel's 8279 is a general purpose keyboard display controller
that simultaneously drives the display of a system and interfaces
a keyboard with the CPU, leaving it free for its routine task.
74
By T.VenkataSridhar, ETC
8279 Pin Diagram
76
By T.VenkataSridhar, ETC
8279 Pin Description Conti…
Vss, Vcc These are the ground and power supply lines for the circuit.
SLo-SL3-Scan Lines These lines are used to scan the keyboard matrix and display digits.
These lines can be programmed as encoded or decoded, using the mode control register.
RLo-RL7-Return Lines These are the input lines which are connected to one terminal of
keys, while the other terminal of the keys are connected to the decoded scan lines. These
are normally high, but pulled low when a key is pressed.
SHIFT The status of the shift input line is stored along with each key code in FIFO in
the scanned keyboard mode. Till it is pulled low with. a key closure it is pulled up
internally to keep it high.
CNTL/STB-CONTROL/STROBED I/P Mode In the keyboard mode, this line is
used as a control input and stored in FIFO on a key closure. The line is a strobe line
that enters the data into FIFO RAM, in the strobed input mode. It has an internal pull
up. The line is pulled down with a key closure.
BD-Blank Display This output pin is used to blank the display during digit switching or
by a blanking command.
OUTAo - OUTA3 and OUTBo-OUTB3 These are the output ports for two 16 x 4 (or
one 16 x 8) internal display refresh registers. The data from these-lines is synchronized
with the scan lines to scan the display and keyboard. The two 4-bit ports may also be
77 used as one 8-bit port.
By T.VenkataSridhar, ETC
Modes of Operation of 8279
The modes of operation of 8279 are:
(i) Input (Keyboard) modes
(ii) Output (Display) modes
Input (Keyboard) Modes 8279 provides three input modes which are:
1. Scanned Keyboard Mode This mode allows a key matrix to be interfaced using
either encoded or decoded scans. In the encoded scan, an 8 x 8 keyboard or in decoded
scan, a 4 x 8 keyboard can be interfaced. The code of key pressed with SHIFT and
CONTROL status is stored into the FIFO RAM.
2. Scanned Sensor Matrix In this mode, a sensor array can be interfaced with 8279
using either encoded or decoded scans. With encoded scan 8 x 8 sensor matrix or with
decoded scan 4 x 8 sensor matrix can be interfaced. The sensor codes are stored in the
CPU addressable sensor RAM.
3. Strobed input In this mode, if the control line goes low, the data on return lines, is
stored in the FIFO byte by byte.
78
By T.VenkataSridhar, ETC
Modes of Operation of 8279
Output (Display) Modes 8279 provides two output modes for selecting the display
options. These are:
2. Display Entry (right entry or left entry mode) 8279 allows options for data entry
on the displays. The display data is entered for display either from the right side or
from the left side.
command words or status words are written or read with Ao = 1 and CS = 0 to or from
8279. The various commands available in 8279 are.
79
By T.VenkataSridhar, ETC
80
By T.VenkataSridhar, ETC
(b) Programmable Clock The clock for operation of 8279 is obtained by dividing the
external clock input signal by a programmable constant called prescaler,
PPPPP is a 5-bit binary constant. The input frequency is divided by a decimal constant
ranging from 2 to 31, decided by the bits of an internal prescaler, PPPPP.
(c) Read FIFO/Sensor RAM The format of this command is given as shown below:
x - don't care
AI - Auto Increment flag
AAA - Address pointer to 8 bit FIFO RAM
This word is written to set up 8279 for reading FIFO/sensor RAM. In scanned
keyboard mode, AI and AAA bits are of no use. The 8279 will automatically drive data bus
for each subsequent read, in the same sequence, in which the data was entered. In sensor
matrix mode, the bits AAA select one of the 8 rows of RAM. If AI flag is set, each
successive read will be from the subsequent RAM location.
81
By T.VenkataSridhar, ETC
(d) Read Display RAM This command enables a programmer to read the display RAM
data.
The CPU writes this command word to 8279 to prepare it for display RAM read operation.
If AI = 1, the address will be automatically, incremented after each read or write to the
display RAM. The same address counter is used for reading and writing.
The IW (Inhibit Write flag) bits are used to mask the individual nibble as shown in
the above command.
The output lines are divided into two nibbles (OUTAo-OUTA3 and OUTBo-
OUTB3 ), those can be masked by setting the corresponding IW bit to 1.
Once a nibble is masked by setting the corresponding IW bit to 1, the entry to
display RAM does not affect the nibble even though it may change the unmasked nibble.
The blank display bit flags (BL) are used for blanking A and B nibbles. Here D0 and D2
corresponds to OUTBo-OUTB3 while D1 and D3 corresponds to OUTAo-OUTA3 for
blanking and masking respectively.
(g) Clear Display RAM
The CD2, CD1, CDo is a selectable blanking code to clear all the rows of the display
RAM as given below. The characters A and B represent the output nibbles
83
By T.VenkataSridhar, ETC
End Interrupt/Error Mode Set
For the sensor matrix mode, this command lowers the IRQ line and enables further
writing into the RAM. Otherwise, if a change in sensor value is detected, IRQ goes high
that inhibits writing in the sensor RAM.
This section briefly describes the formats of the key-code/sensor data in their
respective modes of operation and the FIFO Status Word formats of 8279.
84
By T.VenkataSridhar, ETC
Key-code Data Formats : After a valid key closure, the key code is entered as a byte code
into the FIFO RAM, in the following format, in scanned keyboard mode. The data format
of the key-code in scanned keyboard mode is given below. The key-code format contains
3-bit contents of the internal row counter, 3-bit contents of the column counter and status
of the SHIFT and CNTL keys.
In the sensor matrix mode, the data from the return lines is directly entered into
an appropriate row of sensor RAM, that identifies the row of the sensor that changed its
status.
The SHIFT and CNTL keys are ignored in this mode. RL bits represent the
return lines. Rn represents the sensor RAM row number that is equal to the row number of
the sensor array in which the status change was detected.
85 By T.VenkataSridhar, ETC
FIFO status word
The FIFO status word is used in keyboard and strobed input mode to indicate the error.
Overrun error occurs, when an already full FIFO is attempted an entry. Underrun
error occurs when an empty FIFO read is attempted.
FIFO status word also has a bit to show the unavailability of FIFO RAM because of
the ongoing clearing operation
In sensor matrix mode, a bit is reserved to show that at least one sensor closure
indication is stored in the RAM. The SIB bit shows the simultaneous multiple closure
error in special error mode.
The status word contains FIFO status, error and display unavailable signals.
86
By T.VenkataSridhar, ETC
Interfacing and Programming 8279
Problem 1.
Interface keyboard and display controller 8279 with 8086 at address 0080H. Write an ALP
to set up 8279 in scanned keyboard mode with encoded scan, N-key rollover mode. Use a
16-character display in right entry display format. Then clear the display RAM with zeros.
Read the FIFO for key closure. If any key is closed, store it's code to register CL. Then
write the byte 55 to all the displays, and return to DOS. The clock input to 8279 is 2 MHz,
operate it at 100 kHz.
Solution
Specifications
The 8279 is interfaced with lower byte of the data bus, i.e. Do-D7 Hence the Ao input
of 8279 is connected with address line A1.
The data register of 8279 is to be addressed as 0080H, i.e. Ao = 0. As already
discussed, the data is either read from or written to this address (Ao = 0). For addressing
the command or status word Ao input of 8279 should be 1 (the address line A1 of 8086
should be 1), i.e. the address of the command word should be 0082H.
Figure below shows the interfacing schematic.
The next step is to write all the required command words for this problem.
87
By T.VenkataSridhar, ETC
88
By T.VenkataSridhar, ETC
89
By T.VenkataSridhar, ETC
Interfacing Hardware
90
By T.VenkataSridhar, ETC
Program
Program below gives the ALP required to initialize the 8279 as required.
91
By T.VenkataSridhar, ETC
* Topics beyond syllabus Ends..
92
By T.VenkataSridhar, ETC
End of Interfacing Devices
93
By T.VenkataSridhar, ETC
Intel’s 8086
Introduction to 8086 Microprocessor: Architecture, Register
Organization, Physical Memory Organizations.
94
By T.VenkataSridhar, ETC
8086 Overview
It was the first 16-bit processor having 16-bit ALU, 16-bit registers, internal
data bus, and 16-bit external data bus resulting in faster processing.
AX
BX
CX
DX
96
By T.VenkataSridhar, ETC
Register Organisation
Flag Register
X X X X X X X
Memory Organisation:
www.intel.com
98
By T.VenkataSridhar, ETC