Ilovepdf Merged
Ilovepdf Merged
INTERFACING
CSE2006
• Direct I/O
• Indirect I/O
• String
8086 I/O Instructions
IN and OUT transfer data between an I/O device and the
microprocessor's accumulator (AL, AX or EAX).
The I/O address is stored in:
Register DX as a 16-bit I/O address (variable addressing/Indirect).
The byte, p8, immediately following the opcode (fixed address/Direct).
IN AL,19H; 8-bits data are saved to AL from I/O port 19H
IN AL, DX; 8-bits data are saved to AL from I/O port [DX]
IN AX, DX; 16-bits are saved to AX.
IN AX, 20H 16-bits data are saved to AX from I/O port 20H
OUT DX, AX; 16-bits are written to port DX from AX
OUT 19H, AL; 8-bits are written to I/O port 0019H.
Only 16-bits (A0 to A15) are decoded.
Address connections above A15 are undefined for I/O instructions.
OUTS
80x86 I/O Instructions
DX
Modes of I/O Instructions
• Direct I/O – the port address is one of the operands.
– Address must be 00-FFh.
• IN AL, 27h
• Ports are:
➢ registers (part of the I/O interface)
➢ 8, 16, or 32 bits wide
➢Addressed in the range 0000-FFFFh
➢Accessed with 2 instructions – IN, OUT
Why Buffers
4/3/2021 13
I/O Design in 8086
Any μP-based system when data is sent out by μP, the data on the data-bus must be
latched by the receiver/output device
Data provided by the μP is available only for short period of time (50-1000ns) data must
be latched else it will be lost
When data comes in from a port/memory, data must be input through a tri-state
buffer
I/O Design in 8086
8255 PPI
PPI provides 3, 8-bit I/O ports (A, B and C) in one package Chip can be directly
interfaced to the data bus of 8086.
• The PPI has 24 pins for I/O, programmable in groups of 8/12 pins
(Group A ,B,C)
• The 82C55 (CMOS version) requires wait states if operated with a processor
using higher than an 8 MHz clock.
Pin Diagram of 8255
•PA0 – PA7 – Pins of port A
•PB0 – PB7 – Pins of port B
•PC0 – PC7 – Pins of port C
•D0 – D7 – Data pins for the transfer of data
•RESET – Reset input
•RD’ – Read input
•WR’ – Write input
•CS’ – Chip select
•A1 and A0 – Address pins
Selection of ports
Chip Select.
A LOW on this input selects the chip and enables the communication between the 8255A and the CPU. It is
connected to the decoded address, and A0 & A1 are connected to the microprocessor address lines.
Operating Modes
8255A has three different operating modes
• Mode 0 − In this mode, Port A and B is used as two 8-bit ports and Port C as
two 4-bit ports. Each port can be programmed in either input mode or
output mode where outputs are latched and inputs are not latched. Ports
do not have interrupt capability.
• Mode 1 − In this mode, Port A and B is used as 8-bit I/O ports. They can be
configured as either input or output ports. Each port uses three lines from
port C as handshake signals. Inputs and outputs are latched.
• Mode 2 − In this mode, Port A can be configured as the bidirectional port
and Port B either in Mode 0 or Mode 1. Port A uses five signals from Port C
as handshake signals for data transfer. The remaining three signals from
Port C can be used either as simple I/O or as handshake for port B.
Data Bus Buffer
• It is a tri-state 8-bit buffer, which is used to interface the
microprocessor to the system data bus.
• Data is transmitted or received by the buffer as per the instructions
by the CPU.
• Control words and status information is also transferred using this
bus.
What is tri-state buffer?
A tri-state buffer is similar to a buffer, but it adds an additional
"enable" input that controls whether the primary input is
passed to its output or not. If the "enable" inputs signal is true,
the tri-state buffer behaves like a normal buffer.
Read/Write Control Logic
• This block is responsible for controlling the internal/external transfer
of data/control/status word.
• It accepts the input from the CPU address and control buses, and in
turn issues command to both the control groups.
Internal block diagram of 8255
214 = 16K
8255 can be connected
• It consists of 40 pins and operates in +5V regulated power supply.
• Port C is further divided into two 4-bit ports i.e. port C lower and port
C upper and port C can work in either BSR (bit set rest) mode or in
mode 0 of input-output mode of 8255.
• Port B can work in either mode or in mode 1 of input-output mode.
Port A can work either in mode 0, mode 1 or mode 2 of input-output
mode.
• It has two control groups, control group A and control group B.
Control group A consist of port A and port C upper. Control group B
consists of port C lower and port B.
• Depending upon the value if CS’, A1 and A0 we can select different
ports in different modes as input-output function or BSR. This is done
by writing a suitable word in control register (control word D0-D7).
• Mode 0 –In this mode all the three ports (port A, B, C) can work as
simple input function or simple output function. In this mode there is
no interrupt handling capacity.
• Mode 1 – Handshake I/O mode or strobbed I/O mode. In this mode
either port A or port B can work as simple input port or simple output
port, and port C bits are used for handshake signals before actual
data transmission. It has interrupt handling capacity and input and
output are latched.
• Example: A CPU wants to transfer data to a printer. In this case since
speed of processor is very fast as compared to relatively slow printer,
so before actual data transfer it will send handshake signals to the
printer for synchronization of the speed of the CPU and the
peripherals.
• Mode 2 – Bi-directional data bus mode. In this mode only port A
works, and port B can work either in mode 0 or mode 1. 6 bits port C
are used as handshake signals. It also has interrupt handling capacity.
WR: It stands for write. This control signal enables the write operation.
When this signal goes low, the microprocessor writes into a selected
I/O port or control register.
RESET: This is an active high signal. It clears the control register and
sets all ports in the input mode.
RD: It stands for Read. This control signal enables the Read operation.
When the signal is low, the microprocessor reads the data from the
selected I/O port of the 8255
Interfacing with 8086
Programming 8255
MOV DX 0FFF6h;
MOV AL 80h;
OUT DX AL;
Port A
MOV DX 0FFF0h;
OUT DX AL;
Port B
MOV DX 0FFF2h;
OUT DX AL;
Port C
MOV DX 0FFF4h;
OUT DX AL;
Control word Format
Control word Format
Example
Modes of operation of 8255
Example
Example
Handshaking signal
Handshaking signal
Output Write
MODE 1 (Strobed I/O mode)
• Two groups – Group A and group B are available for strobe data transfer.
• Each group contains one 8 bit data I/O port and one four bit control /
data port.
• Both the input and outputs are latched.
• Out of 8-bit port C , PC0- PC2 are used to generate control signals for
port B and PC3- PC5 are used to generate control signals for port A.
• The lines PC6- PC7 may be used as independent data lines.
MODE 2 (Strobed Bidirectional I/O mode)
0 1 1 1 0 0 0 0
Counter selected with the A1, A0 inputs, the CLK input of the selected Counter must be inhibited by
using either the GATE input or external logic. Otherwise, the count may be in the process of changing
when it is read, giving an undefined result. Two I/O read operation are performed by the MPU
1. The first I/O operation reads the low order byte.
2. The second I/O operation reads high order byte.
Latching counter0
MOV DX, C_REG
MOV AL, 00000000B ;
OUT DX, AL
Reading counter0
MOV DX, CNTR0
IN AL, DX
Read-Back Command
• This command is used to read several counters at a time. It eliminates the need of writing
separate counter-latch commands for different counters.
• It allows the user to check the count value, programmed Mode, and current states of
• the OUT pin and Null Count flag of the selected counter/ counters. The read back
command is written to the Control Word Register.
• is reprogrammed). The counter is automatically unlatched when read, but other counters
remain latched until they are read.
Read-Back Command
The read-back command may also be used to latch status information of selected
counter(s) by setting STATUS bit D4 = 0. Status must be latched to be read; status
of a counter is accessed by a read from that counter.
Read-Back Command
Example:
• –each mode functions with the CLK input, the gate (G) control
signal, and OUT signal.
Modes of counting
Mode 0 –Interrupt on Terminal count
Mode 0 –Interrupt on Terminal count
Mod 0 : Case 1
Mod 0 : Case 2
Mod 0 : Case 3
Mode 1 –Hardware retriggerable one-shot
Mod 1: Case 1
Mod 1: Case 2
Mod 1: Case 3
Modes of counting : Mode 1
Mode 2 Rate Generator (Divide by N counter)
Case 1
Case 2
Case 3
Mode 3 -Square Wave Generator
Case1 :Even count
Case2 :Odd count
Mode 4 – Software triggered strobe
Case1
Case 2
Case 3
Mode 5 – Hardware triggered strobe
Case 1
Case 2
Case 3
Reading the counter values
8254 Read Back control word
Status Register( 8254 only)
Example :1
• Draw the interface diagram and write a program for 8253 interface
starting at 50H,
• Counter 0 used in mode 1, MSB+LSB, binary, to be loaded with 3080H
• Counter1 used in mode 0, LSB only, BCD to be loaded with 99.
Example:1
Example:1
Counter 0 used in mode 1, MSB+LSB, binary, to be loaded with 3080H
Counter1 used in mode 0, LSB only, BCD to be loaded with 99.
10
2
Timer 8253
What is 8253/8254?
❖ It is not possible to create a time delay using delay routines
❖ Intel’s programmable timer 8253/8254 will generate an accurate time
delay
❖ While 8253/8254 are capable of taking care of the time delays and
timing of the process, the microprocessor can be free from these tasks
and perform other tasks
❖ This reduces the software overhead on the microprocessor
Characteristic features of 8253
❖ Has three counters each with maximum count rate of 2.6 MHz.
❖ Thus, it is possible to maintain 3 separate delays or maintain 3
independent counters simultaneously
❖ 8253 communicates with the microprocessor’s bus using D0 to D7
bidirectional data buffer
Block and pin diagrams
Cont’d
❖ The three counters are independent of each other but are similar in
organization
❖ They are 16 bit counters that can operate either in BCD or Hexadecimal
mode
❖ The mode control word register contains the information that is used for
writing or reading count value into or from the respective count registers
using OUT and IN instructions.
❖ The control word can only be written and cannot be read
❖ When CS’ is low, it enables the Timer 8253
Various control inputs
Control word register
❖ A control word must be written in the respective control register by
the microprocessor to initialize the 8253.
❖ Depending upon the control word decided by the user, the counter
works independently.
❖ Only after the data is put on the data bus and a falling edge appears in
the clock signal of the peripheral device, the count can be written to the
counter
Cont’d
Cont’d
Modes of counting
Mode 0 – interrupt or terminal count
▪ Output is initially low after the mode is set.
▪ Output remains low even if the count value is loaded in the counter
▪ The counter starts decrementing the count after the falling edge of the
clock, if the GATE input is high.
▪ At each falling edge, the counter decrements till the count becomes 0.
▪ Once count becomes 0, the output goes high and remains high until the
selected control word register or the count register is loaded with a new
mode or count respectively.
▪ The high output can be used to interrupt the processor whenever
required by setting a suitable count.
Cont’d
▪ When the count register is filled with a new count value while the
previous count is executing, then the following sequence of operations
occur.
▪ The first byte of the new count stops the previous count.
▪ The second byte, when written, starts the new count by terminating the
previous count
▪ For normal counting, the GATE signal should be active high.
▪ When GATE goes low, the counting is terminated and the current count
is latched until the GATE goes high again.
Cont’d
Mode 1 – programmable one shot mode
▪ In this mode, 8253 can be used as a monostable multivibrator
▪ The duration of the quasistable state of the multivibrator is defined by the
count value in the count register.
▪ The GATE input is used a a trigger input in Mode 1.
▪ The output remains high till a suitable count is loaded in the count register
and a trigger is applied
▪ After the trigger is applied, the output goes low and remains low till the
count becomes 0.
▪ When a new count value is filled in the count register when a previous count
is going on, it does not affect the count until there is a trigger given by the
GATE
▪ The new count starts after the new trigger pulse
Cont’d
Mode 2 – rate generator or divide-by-n counter
▪ If N is loaded as the count value, then after N-1 cycles, the output
becomes low only for one cycle
▪ The count N is reloaded and again the output becomes high and
remains for another N-1 cycles
▪ The output is normally high after initialization
▪ A low on the GATE signal can also force the output to be high
▪ If the GATE goes high, the counter starts counting from the initial
value
Cont’d
• The count down starts and whenever the count becomes zero,
another active low pulse is generated at the output.
• They last for one clock cycle
• The number of input clock pulses between the two active low pulses
is equal to the count value
Cont’d
Mode 3 – square wave generator
• When the count N is even then for half of the count the count is high
and for the rest half the count is low.
• If the count is odd, the first clock pulse decrements it by 1, making it
even
• Then the output goes high for the first half of the count and goes low for
the remaining half, thus generating a square wave.
• In case of odd count the output is high for a longer duration and low for
a shorter duration
• If the loaded count value N is odd, then the output is high for (N+1)/2
cycles and low for (N-1)/2 cycles.
continued
Mode 4 – Software triggered strobe
• Once the mode is set, the output goes high
• When count is loaded, the count starts.
• When count becomes 0, the output goes low for one cycle and then
becomes high again
• This low pulse can be used as a strobe, while interfacing the
microprocessor with other peripheral devices.
• When the GATE goes low, the count is latched
• If a new count is loaded in the count register when the previous
count is in progress, then the new count is accepted after one clock
cycle.
Mode 4
Mode 5 – to generate a delayed strobe
❖ When there is a rising edge at the trigger input, a strobe is created
❖ Once the mode is set and the count is given, the output goes high
❖ The counter starts counter after the rising edge of the trigger input
❖ When the count becomes 0, then the output becomes low for one
clock cycle.
Mode 5
weblinks
• https://nptel.ac.in/courses/108/107/108107029/
• https://nptel.ac.in/content/storage2/courses/108105057/Pdf/Lesson-
14.pdf
Input & Output Interface
Bi-Directional Buffer
Latch
Max 64
Pin diagram
continued
❖ CS – active low chip select signal for enabling 𝑅𝐷 and 𝑊𝑅 operations.
❖ 𝑅𝐷 - Active low read enable input.
❖ 𝑊𝑅 - This pin is an active low write enable input pin to 8259
❖ 𝐷7 − 𝐷0 - bidirectional data bus that carries 8-bit data either to a
control word or from a status word register. This can also carry interrupt
vector information.
❖ 𝐶𝐴𝑆0 − 𝐶𝐴𝑆2 Cascade lines – If more interrupts are required, the 8259A
is used in a cascade mode in which one 8259A is the master and 8 other
8259As as slaves, thus forming 64 vectored interrupt. These three lines
act as select lines for addressing the slaves.
continued
❖ 𝑆𝑃/ 𝐸𝑁 - When the chip is used in buffered mode, it can be used as a
buffer enable. Else, this pin is used as an input to designate whether
the chip is used as a master (𝑆𝑃 = 1) or a slave (𝐸𝑁 =0)
❖ INT - This pin goes high whenever a valid interrupt is received.
❖ 𝐼𝑅0 - 𝐼𝑅7 - Act as inputs to accept interrupts requests to CPU.
❖ 𝐼𝑁𝑇𝐴 - Interrupt acknowledgement
Interrupt sequence
❖ When one or more IR lines go high, the corresponding bits are set in
the IRR
❖ It finds the highest priority signal and sends an INT signal to the CPU
❖ CPU acknowledges with 𝐼𝑁𝑇𝐴 pulse.
❖ Upon reception of 𝐼𝑁𝑇𝐴 pulse, the highest priority bit of ISR and the
corresponding bit of IRR are set.
❖ The 8086 will initiate another 𝐼𝑁𝑇𝐴 pulse.
❖ Now, 8259A releases an 8-bit pointer on the data bus from where it is
read by the CPU.
❖ If automatic end of interrupt (AEOI) mode is programmed, the ISR bit
is reset by the end of the second 𝐼𝑁𝑇𝐴 pulse.
❖ Otherwise, ISR bit remains set until an EOI signal is issued.
Command words
Command words
Max 64
Addressing 8259A
➢Only Two Addresses per 8259A.
ICW1 : Mandatory
8259A ICWs
8259A ICWs
ICW2 : Mandatory
8259A ICWs
OCW1 : Non-Mandatory
4/20/2021 15
Problem
4/20/2021 16
Problem
4/20/2021 17
Problem
Problem
4/20/2021 19
Problem
Problem
4/20/2021 21
Problem
4/20/2021 22
Problem
4/20/2021 23
Problem
4/20/2021 24
Problem
Problem
4/20/2021 26
8255A PPI/8254 Timer
& 8259A PIC
Problem-1
4/28/2021 18
8
Problem-4
Problem-4
Problem-4
Problem-5
19
4
Problem-6
Show 8259A interfacing connections with 8086 at the address 074x. Write an ALP
to initialize the 8259A in single level triggered mode non buffered on special fully
nested mode. Then set the 8259A to operate with IR6 masked and specific EOI
mode.
19
5
Problem-6
Show 8259A interfacing connections with 8086 at the address 074x. Write an ALP
to initialize the 8259A in single level triggered mode non buffered on special fully
nested mode. Then set the 8259A to operate with IR6 masked and specific EOI
mode. Vector address of IR1is 81H.
Problem-6
Show 8259A interfacing connections with 8086 at the address 074x. Write an ALP
to initialize the 8259A in single level triggered mode non buffered on special fully
nested mode. Then set the 8259A to operate with IR6 masked and specific EOI
mode. Vector address of IR1is 81H.
19
7
Problem-6
Show 8259A interfacing connections with 8086 at the address 074x. Write an ALP
to initialize the 8259A in single level triggered mode non buffered on special fully
nested mode. Then set the 8259A to operate with IR6 masked and specific EOI
mode. Vector address of IR1is 81H.
Problem-6
INTERRUPT PROC NEAR
MOV AL, AFH ; Loading ICW1 to AL
MOV DX, 0740H ; Loading Address of ICW1 to DX (Variable port addressing)
OUT DX, AL ; Sending ICW1 to port (address: 0740H ) of 8259A
19
9
THANK YOU !
[email protected]
HTTPS://SITES.GOOGLE.COM/VIEW/ARVINDK
MICROPROCESSOR AND
INTERFACING
CSE2006
• Other converters are available that convert from 10-, 12-, or 16-bit binary
numbers into analog voltages.
DAC0830
• The number of voltage steps generated by the converter is equal to the number of binary
input combinations.
Because this is an 8-bit converter, its output step voltage is defined as –VREF
(reference voltage), divided by 255. The step voltage is often called the resolution of the
converter
interfacing Adc with 8086
❖ In most cases, PPI 8255 is used to interface the ADC to the microprocessor
❖ ADC is considered as input device to the microprocessor that sends an
initializing signal to the ADC to start the analog signal conversion
❖ There is a pulse which is called the start of conversion (SOC) signal
❖ A2D conversion is a slow process and the microprocessor has to wait until
the conversion is over.
❖ Once the conversion is over, the end of signal (EOS) is sent to inform the
microprocessor about the same and the result is ready at the output buffer
of ADC
Continued
❖ Issuing SOC, reading EOC, getting the results are all done by PPI 8255
❖ The time taken by the ADC for the conversion of the analog signal to
digital signal is called conversion delay
❖ It can range from a few microseconds to a few hundred milli seconds
❖ Selection of appropriate ADC – speed, resolution and cost factor.
General algorithm for interfacing
❖ Ensure the stability of the analog input given to the ADC
❖ Issue SOC of ADC
❖ Read EOC to mark the end of conversion
❖ Read the digital output from the output buffer of ADC
❖ The analog input must be a constant value from the start to end of
conversion process
❖ This is done using a sampling and hold circuit
❖ The 8086 gives the hold signal to the sample and hold circuit
ADC 0808/0809
❖ Successive optimization converters – one of the fastest techniques
❖ Conversion delay is 100 microsecs for 640kHz
❖ Do not need an external zero or full scale adjustments
❖ 8 input analog signals can be provided
❖ Out of these 8 inputs, only 1 input can be selected for conversion by
using address lines ADD A, ADD B and ADD C
Address lines for conversion
Analog I/P Address lines
selected C B A
I/P 0 0 0 0
I/P 1 0 0 1
I/P 2 0 1 0
I/P 3 0 1 1
I/P 4 1 0 0
I/P 5 1 0 1
I/P 6 1 1 0
I/P 7 1 1 1
Pin diagram
Example problem for interfacing
continued
Interfacing 8086 with 0808
Interfacing digital to analog converters
❖ DACs convert binary numbers into their analog equivalent voltages
❖ Applications of DAC
❖Digitally controlled gains
❖Motor speed controls
❖Programmable gain amplifiers
AD 7523 8-bit multiplying dac
❖ Intersil’s AD 7523 is a 16 pin, multiplying DAC containing R-2R ladder with
R=10 K for digital to analog conversion along with single pole double throw
NMOS switches to connect the digital inputs to the ladder.
continued
❖ The supply range extends from +5V to +15V
❖ The maximum analog output value is +10V, when all the digital input
values are at logic high state
❖ To save the DAC from negative transients, a Zener diode is connected
between OUT1 and OUT2.
❖ An OPAMP is used as a current-to-voltage converter at the output of
AD 7523 in order to generate an equivalent output voltage for the
current produced.
Example problem to interface dac with 8086
Sawtooth wave
❖ Port A is designed to send the digital data as inputs
to the converter
❖ The ramp starts from 0V and hence AL is moved
with 00H.
❖ To increment the ramp, the value of AL must be
incremented till it reaches FFH
❖ After that the sawtooth again starts from 00H and
this procedure repeats
Dac 0800 8-bit digital to analog converter
❖ DAC 0800 is a monolithic 8-bit DAC manufactured by National
Semiconductor.
❖ It can work at various voltages from 4.8V to 18V, usually, 5V or 12 V
Pin diagram
example
Triangular wave
Interfacing 7-segment display with 8086
Types of 7-segment displays
continued
7-segment
display
DISPLAY FORMAT
❖ Let us consider common anode display. The connection
table is as follows
❖ Logic 0 – turn on segment, logic 1 – turn off segment
7 – segment display interfacing
Equivalent hex values
Weblink for 7 segment display and 4x4
keyboard interfacing
• https://www.youtube.com/watch?v=Q1I4-8fVShA
• https://www.youtube.com/watch?v=7V69bSFBnVQ
https://nptel.ac.in/content/storage2/courses/106108100/pdf/T
eacher_Slides/mod3/M3L7.pdf
THANK YOU !
[email protected]
HTTPS://SITES.GOOGLE.COM/VIEW/ARVINDK
Peripheral Interfacing
Data Communications
• Data communications refers to the ability of one computer to exchange
data with another computer or a peripheral
• Physically, the data comm. path may be a short, 5 to 10 feet ribbon cable
connecting a microcomputer and parallel printer; or it might be a high
speed telecommunications port connecting two computers thousands of
miles apart.
• Standard data communication interfaces and standards are needed
• Centronic’s parallel printer interface
• RS-232 defines a serial communications standard
• We focus on serial I/O this week
• 8251 USART (Universal Synchronous/Asynchronous
Receiver/Transmitter) is the key component for converting parallel data
to serial form and vice versa
• Two types of serial data communications are widely used
– Asynchronous communications
– Synchronous communications
Types of Transmission
Asynchronous Communications
Receive data
D0
parallel data
- D7
RD Read Control
WR Write control
CS Chip Select
RESET Reset
BRKDET DetectBreak
GND
Ground(0V)
2 Signal Description of 8251
D0 – D7: This is an 8-bit data bus used to read or write status, command
word or data from or to the 8251A.
RD: This active-low input to 8251A is used to inform it that the CPU is
reading either data or status information from its internal registers. This
active-low input to 8251A is used to inform it that the CPU is writing data or
control word to 8251A.
TXC (Transmitter Clock Input): This transmitter clock input controls the rate
at which the character is to be transmitted. The serial data is shifted out on the
successive negative edge of the TXC.
TXD (Transmitted Data Output): This output pin carries serial stream of the
transmitted data bits along with other information like start bit, stop bits and
parity bit, etc.
RXC (Receiver Clock Input): This receiver clock input pin controls the rate at
which the character is to be received.
RXD (Receive Data Input): This input pin of 8251A receives a composite
stream of the data to be received by 8251 A.
RXD (Receive Data Input): This input pin of 8251A receives a
composite stream of the data to be received by 8251 A.
RXRDY (Receiver Ready Output): This output indicates that the 8251A
contains a character to be read by the CPU.
7 6 5 4 3 2 1 0 Mode register
7 6 5 4 3 2 1 0 Mode register
• PPI
Programmable Peripheral
Interface
20
Intel 8255 PPI
PPI – Programmable Peripheral Interface
It is an I/O port chip used for interfacing I/O
devices with microprocessor
Very commonly used peripheral chip
Knowledge of 8255 essential for students in the
Microprocessors lab for Interfacing experiments
21
About 82C55
• The 82C55 is a popular interfacing component, that
can interface any TTL-compatible I/O device to a
microprocessor.
• It is used to interface to the keyboard and a parallel
printer port in PCs (usually as part of an integrated
chipset).
• Requires insertion of wait states if used with a
microprocessor using higher that an 8 MHz clock.
• PPI has 24 pins for I/O that are programmable in
groups of 12 pins and has three distinct modes of
operation.
82C55 : Pin Layout
8255 Control Word
Basic Mode Definitions and Bus
Int
• Mode 0
– Basic I/O
• Mode 1
– Strobe I/O
• Mode 2
– Bi-Dir Bus
Programming 8255
8255 has three operation modes: mode 0, mode 1, and mode 2
11-26
27
8255 PPI contd.
3 ports in 8255 from user’s point of view
- Port A, Port B and Port C.
Port C composed of two independent 4-bit ports
- PC7-4 (PC Upper) and PC3-0 (PC Lower)
A1 A0 Selected port
0 0 Port A
0 1 Port B
1 0 Port C
1 1 Control port
28
8255 40 pin DIP
7404 A0
M/IO*
Reset
In this mode, ports A, B are used as two simple 8-bit I/O ports
port C as two 4-bit ports.
Each port can be programmed to function as simply an input port or
an output port. The input/output features in Mode 0 are as follows.
31
8255 PPI Contd.
Mode 1: Input or Output with Handshake
33
8255 Handshake signals
34
8255 Handshake signals Contd.
36
8255 MD Control word
Control port having Mode Definition (MD) control word
1 M2A M1A I/P A I/P CU M1B I/P B I/P CL
Means Mode
1 - PCU as input 1 -PCL as input
Definition
control word 0 - PCU as output 0 -PCL as output
1 - PA as input 1 - PB as input
M2A M1A 0 - PA as output 0 - PB as output
0 0 Port A in Mode 0 1 – Port B in Mode 1
0 1 Port A in Mode 1 0 – Port B in Mode 0
1 0/1 Port A in Mode 2
37
8255 MD Control word Contd.
Ex. 1: Configure Port A as i/p in Mode 0, Port B as o/p in
mode 0, Port C (Lower) as o/p and Port C (Upper) as i/p
ports.
Required MD control word:
1 0 0 1 1 0 0 0 = 98H
MD control PC Lower as o/p
PA in Mode 0 PB as o/p Reqd. instrns.
PA as i/p PB in Mode 0 MOV AL, 98H
PC Upper as i/p OUT 7FH, AL
38
8255 MD Control word Contd.
Ex. 2: Configure Port A as i/p in Mode 1, Port B as o/p in
mode 1, Port C7-8 as i/p ports. (PC5-0 are handshake lines,
some i/p lines and others o/p. So they are shown as X)
Required MD control word:
1 0 1 1 1 1 0 X = BCH or BDH
MD control PC3-0 as don’t care
PA in Mode 1 PB as o/p Reqd. Instrns.
PA as i/p PB in Mode 1 MOV AL,BCH
PC Upper(C7-8) as i/p OUT 7FH, AL
39
8255 Contd.
There are 2 control words in 8255
Mode Definition (MD) Control word and
Port C Bit Set / Reset (PCBSR) Control Word
40
8255 MD Control word Contd.
Ex. 3:Configure Port A in Mode 2, Port B as o/p in mode 1.
(PC5-0 are handshake lines for Port A and PC2-0 are
handshake signals for port B)
Required MD control word:
1 1 0 X X 1 0 X = C4H / C5H..
MD control PC3-0 as handshake
PA in Mode 2 PB as o/p Reqd. instrns.
PA bidirectional PB in Mode 1 MOV AL, C4H
PC7-0 as handshake OUT 7FH, AL
41
8255 PCBSR Control word
Control port having Port C Bit Set / Reset control word
0 X X X SB2 SB1 SB0 S/R*
Select bit of PC 1 - Set to 1
PC bit set
Don’t to be set / reset 0 - Reset to 0
/ reset
cares 0 0 0 Bit 0 of Port C
control
word 0 0 1 Bit 1 of Port C
:
:
1 1 1 Bit 7 of Port C
42
8253 / 8254 Timer
• To program a given counter to divide the
CLK input frequency, one must send the
divisor to that specific counter’s register.
• Although all three counters share the same
control register, the divisor registers are
separate for each counter
• Example: given the port addresses for
8253/54: Counter 0: 94H Counter 1:
95H
Counter 2: 96H Engr 4862 Microprocessors
Control Reg: 97H
8253 / 8254 Timer
• Task1: program counter 0 for binary counter
for mode 3 to divide CLK0 by number 4282
(BCD)
MOV AL, 0011 0111B
OUT 97H, AL
MOV AX, 4282H (BCD needs H)
OUT 94H, AL (Low Byte)
MOV AL, AH
OUT 94H, AL (High Byte)
• OUT0 = CLK0 /Engr
42824862 Microprocessors
Shape of the 8253/54 Output
• Given CLK = 1.193 MHz, the clock period of
input frequency is 838 ns
• If the number N loaded into the counter is
even, both high and low pulse are the same
length, which is N/2 * 838 ns
• If the number N loaded into the counter is
odd, the high pulse is (N+1)/2 * 838 ns and
the low pulse is (N–1)/2 * 838 ns
• If N is odd, the high portion of the output
square wave is slightly wider than the low
portion Engr 4862 Microprocessors
8253/54 Operation Modes
• Mode 0: Interrupt on terminal count
– The output is initially low, and remain low for the
duration of the count if GATE=1. When the
terminal count is reached, the output will go
high and remain high until a new control word
or new count number is loaded
• Width of low pulse = N * T, where T is clock period
– Example: GATE=1 and CLK = 1 MHz
Clock count N = 1000
John Uffenbeck
The 80x86 Family: Design, Copyright ©2002 by Pearson Education, Inc.
Upper Saddle River, New Jersey 07458
Programming, and Interfacing, 3e All rights reserved.
FIGURE 9-9 Example illustrating the difference between the rotate-on-nonspecific-EOI command and the rotate-on-specific-
EOI command.
Modes
• Fully Nested mode
• Special Fully Nested mode
• Nonspecific Rotating
• Specific Rotating
• Special Mask
• Polling
FIGURE 9-11 8259A initialization control word format. (Courtesy of Intel Corporation.)
John Uffenbeck
The 80x86 Family: Design, Copyright ©2002 by Pearson Education, Inc.
Upper Saddle River, New Jersey 07458
Programming, and Interfacing, 3e All rights reserved.
Features of 8279
The important features of 8279 are,
• Simultaneous keyboard and display operations.
• Scanned keyboard mode.
• Scanned sensor mode.
• 8-character keyboard FIFO.
• 1 6-character display.
• Right or left entry 1 6-byte display RAM.
• Programmable scan timing.
Pin details
000DDMMM
Mode set: Opcode 000.
DD sets displays mode.
MMM sets keyboard mode.
MMM
100ZAAAA
87
8237 pins
CLK: System clock
CS΄: Chip select (decoder output)
RESET: Clears registers, sets mask register
READY: 0 for inserting wait states
HLDA: Signals that the μp has relinquished buses
DREQ3 – DREQ0: DMA request input for each channel
DB7-DB0: Data bus pins
IOR΄: Bidirectional pin used during programming
and during a DMA write cycle
IOW΄: Bidirectional pin used during programming
and during a DMA read cycle
EOP΄: End of process is a bidirectional signal used as input to terminate
a
DMA process or as output to signal the end of the DMA transfer
A3-A0: Address pins for selecting internal registers
A7-A4: Outputs that provide part of the DMA transfer address
HRQ: DMA request output
DACK3-DACK0: DMA acknowledge for each channel.
AEN: Address enable signal
ADSTB: Address strobe
MEMR΄: Memory read output used in DMA read cycle
MEMW΄: Memory write output used in DMA write cycle
88
8237 pin
Diagram
89
A 8237 DMA application
DMA ARCHITECTURE
90
8237 registers
• 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 91
• MR (Mode Register):
92
• MR (Mask
Register):
• SR (Status
Register): Shows
the status of each
DMA channel
93
8237 Software commands
94
8237 Software commands
Clear First/Last Flip-Flop - This command is executed prior to writing or reading
new address or word count information to the 82C37. This command initializes the
flipflop to a known state (low byte first) so that subsequent accesses to register
contents by the microprocessor will address upper and lower bytes in the correct
sequence.
Set First/Last Flip-Flop - This command will set the flip-flop to select the high byte
first on read and write operations to address and word count registers.
Master Clear - This software instruction has the same effect as the hardware
Reset. The Command, Status, Request, and Temporary registers, and Internal
First/Last Flip-Flop and mode register counter are cleared and the Mask register is
set. The 82C37A will enter the idle cycle.
Clear Mask Register - This command clears the mask bits of all four channels,
enabling them to accept DMA requests.
Clear Mode Register Counter - Since only one address location is available for
reading the Mode registers, an internal two-bit counter has been included to select
Mode registers during read operation. To read the Mode registers, first execute the
Clear Mode Register Counter command, then do consecutive reads until the
desired channel is read. Read order is channel 0 first, channel 3 last. The lower
two bits on all Mode registers will read as ones.
95
8237 block diagram
96
Initiating a DMA transaction
Save the current interrupt status and disable
interrupts by executing the CLI instruction
Disable the channel that will be used for the
transaction
Reset the flip-flop by writing a value of 0X to the
register
Set the Mode Register
Set the Page Register
Set the Offset Register
Set the Block Size Register
Enable the channel that will be used for the
transaction
Restore the interrupt status
97
A/D Interfacing
D/A INTERFACING
DEEPAK.P
D/A Interfacing
• 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.
D/A Interfacing
D/A Interfacing
D/A Interfacing
D/A Interfacing
D/A Interfacing
D/A Interfacing
D/A Interfacing
• AD 7523 8-bit Multiplying DAC : This is a 16 pin
DIP, multiplying digital to analog converter,
containing R-2R ladder for D-A conversion along
with single pole double thrown NMOS switches to
connect the digital inputs to the ladder.
Sub
Q.No. . Question Description Marks
Sec.
1. a) A hypothetical CPU has a parallel address bus, a parallel data bus, a RD and WR active [5]
LOW control signals. Two ROMs of size 4K words each and two RAMs of sizes 16K and
8K bytes, respectively, are to be connected to the CPU. The memories are to be so
connected that they fill the address space of the CPU as per the memory map shown in the
figure. Assume that chip select signals are active LOW.
i) What is the maximum number of lines that could be dedicated by the CPU for
the address lines?
2. In an 8086 based micro system, How will you make the micro system work as a single
processor system? With timing signals explain how it read and write in single processor
[10]
mode.
Page 1 of 4
Min mode explanation with diagram (5)
Timing diagram (5)
DATA SEGMENT
X DW 2662H
TEMP DW 0H
MES DB 10,13,'THE WORD IS NIBBLEWISE PALINDROME $'
MES1 DB 10,13,'THE WORD IS NOT NIBBLEWISE PALINDROME $'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AX,X
MOV BX,X
MOV CL,04
AND AX,0000FH
AND BX,0F000H
ROL BX,CL
CMP AX,BX
3. JNZ TER [10]
MOV AX,X
ROR AX,CL
MOV BX,AX
AND AX,000FH
ROR BX,CL
AND BX,000FH
CMP AX,BX
JNZ TER
MOV AH,09H
LEA DX,MES
INT 21H
JMP LAST
TER:MOV AH,09H
LEA DX,MES1
INT 21H
LAST:MOV AH,4CH
INT 21H
CODE ENDS
END START
4. Write an ALP in 8086 using procedural call to get your registration number from keyboard
and segregate the registration number to identify the year of admission, programme name
and four digit register number. Also compare and contrast procedural call and macro.
1. String segregation (3) [10]
2. INT 21 H to display the content the appropriate message (3)
3. Compare procedural call and macro (4)
Assume that address decoding is done such that when ICW1 is to be used, the port address [10]
5.
is C0H and for other ICWs the address is C2H.
Write an initialization instruction for setting up the system with the following
Page 2 of 4
specifications:
i) The system has a single 8259, with edge triggered interrupt inputs and interrupt type
numbers from 90H,91H and 92H for IR0 to IR2.
ii) It should also operate in slave buffered mode with normal EOI.
1) Control word identification (4)
2) Initialization instructions (3)
3) Code for full configuration (3)
Interface an 8255 with 8086 at 0010H as an I/O address of port A. Interface four 7-segment [10]
6.
displays with 8255.Each display has a enable pin, connect those enable pins at port B to
select the digit positions and the display data is transferred to the 7-segment at port A.
Write a sequence of instruction to display ‘1’,’2’,’3’ and ‘4’ over the four displays
continuously as per their positions starting with ‘1’ at the least significant position and
show the circuit connections.
1) Control word identification (4)
2) Seven segment manipulations (3)
3) Code for full configuration (3)
Write an 8087 assembly language program that determine the volume of the given [10]
7.
container with diameter “d=5cm” and height “h=3.5cm”. Illustrate the outcome of result in
single precision format and write the expected output in Hex format.
8. Write an 8087 program to verify the equation 12sin2 θ+cos θ = 6 and copy the control word [10]
in AX register and also analysis the impact of conditional codes.
8087 program to verify the equation [12sin2 θ+cos θ = 6] for given value of X.
(8)
data segment
oneighty dd 180
theta dd 30.156
x dd ?
y dd ?
h dd ?
result dd ?
data ends
code segment
assume cs:code,ds:data
Page 3 of 4
start:mov ax,data
mov ds,ax
finit
fld oneighty
fld theta
fldpi
fmul
fdiv
fptan
fstp x
fst y
fmul st(0),st(0)
fld x
fmul st(0),st(0)
fadd
fsqrt
fld x
fdiv st(0), st(1)
fmul st(0), st(0)
fld y
fdiv st(0), st(2)
Conditional codes (2)
Compare the features of 8086, 80286 & 80386.
9. a) [5]
Minimum 5 points about comparison each carry one mark(5)
Illustrate and compare the register organisation in 8086 and 80386.
b) [5]
Diagram of 8086 and 80386 register organization (2)
Explanation with compare and contrast (3)
10. Draw the architecture of 80286. Explain the working of addressing unit in Protected and
Real mode.
1. Architecture (3)
[10]
2. Explanation of the architecture(2)
3. The working of addressing unit in Protected and Real mode with appropriate
diagram(5)
Page 4 of 4