Lecture12 Thirdmicroprocessorc
Lecture12 Thirdmicroprocessorc
net/publication/340163710
CITATIONS READS
0 259
1 author:
Hadeel N Abdullah
University of Technology, Iraq
75 PUBLICATIONS 257 CITATIONS
SEE PROFILE
All content following this page was uploaded by Hadeel N Abdullah on 25 March 2020.
Lecture TEN
DATA TRANSFER USING I/O
STRUCTURE
4
Lecture 10: Data Transfer using I/O Structure / Assist. Prof. Dr. Hadeel N. Abdullah
Function of Pins
RD (read): this signal enables the read operation. When the signal is low , microprocessor
reads data from a selected I/O port of 8255.
WR (write): this control signal enables the write operation.
RESET: It clears the control registers and sets all ports in input mode.
CS , A0,A1: these are device select signals connected to a decoded address and A0,A1 are
connected to A0,A1 of microprocessor.
5
Lecture 10: Data Transfer using I/O Structure / Assist. Prof. Dr. Hadeel N. Abdullah
Operating Modes Of 8255
Mode 2: port A can be set up for Bidirectional Data Transfer using handshake
signals from port C, and port B can be set up either in mode0 or mode 1.
6
Lecture 10: Data Transfer using I/O Structure / Assist. Prof. Dr. Hadeel N. Abdullah
Control Word Register
1. Bit set/Reset (BSR) mode
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 0 0 0 1 0
; port B is an input
; port A is an output port
Example 2: Write down 82C55 control word that set Port A and Port Cupper as input in mode 1, and set Port Clower
and Port B as output in mode 0.
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 1 0 0 1 1
0 1 1 0 0 1 0 1
Example 4: What is the mode and I/O configuration for ports A, B, C of an 82C55 after its control register is loaded
with 72H.
Solution: D7 D6 D5 D4 D3 D2 D1 D0
0 1 1 1 0 0 1 0
9
Lecture 10: Data Transfer using I/O Structure / Assist. Prof. Dr. Hadeel N. Abdullah
Keyboard/Display Interfaces to 82C55A
10
Example 5: In 8086's 8-bit isolated I/O system, an 82C55 PPI is connected so that the address of A, B, C ports, and
Control register are 4D08H, 4D09H, 4D0AH and 4D0BH respectively.
a) Draw the circuit diagram.
b) Write program to set Register A, B as input and Register C as output (all in mode0). Then continuously receive two
unsigned number from Registers A and B, compare them and output the larger to Register C.
The program
MOV AL, 92H
MOV DX, 4D0BH
OUT DX, AL
again: MOV DL, 08H (because DH is the same)
IN AL,DX
MOV BL, AL
INC DL
IN AL, DX
CMP AL, BL
JNC no_exchange
MOV AL, BL
no_exchange: INC DL
OUT DX, AL
MOV CX, FFFFH
delayloop: DEC CX D7 D6 D5 D4 D3 D2 D1 D0
JNZ delayloop 1 0 0 1 0 0 1 1
11
JMP again
Direct Memory Access (DMA)
A direct memory access (DMA) is an operation in which data is copied (transported) from one resource to
another resource in a computer system without the involvement of the CPU.
The task of a DMA-controller (DMAC) is to execute the copy operation of data from one resource location to
another. The copy of data can be performed from:
I/O-device to memory
memory to I/O-device
memory to memory
I/O-device to I/O-device
Lecture 10: Data Transfer using I/O Structure / Assist. Prof. Dr. Hadeel N. Abdullah 16
8086 Interrupt
An interrupt is used to cause a temporary halt in the execution of program.
The meaning of ‘interrupts’ is to break the sequence of operation.
While the Microprocessor is executing a program, an ‘interrupt’ breaks the normal sequence of
execution of instructions, diverts its execution to some other program called Interrupt Service
Routine (ISR).
After executing ISR, IRET returns the control back again to the main program. Interrupt
processing is an alternative to polling.
Types of Interrupts
The following figure shows
the types of interrupts we have in
an 8086 microprocessor:
Lecture 10: Data Transfer using I/O Structure / Assist. Prof. Dr. Hadeel N. Abdullah 17
Sources of Interrupt
An 8086 interrupt can come from any one of the following three sources:
1) An external signal applied to the non-maskable interrupt (NMI 17 pin) pin or to the interrupt
(INTR 18 pin) pin. An interrupt caused by a signal applied to one of these inputs is called
hardware interrupt.
2) The execution of the Interrupt instruction (INT n), where n is the interrupt type that can take
any value between 00H and FFH. This is called software interrupt.
3) Interrupt raised due to some error condition produced in 8086 instruction execution
process. (Divide by zero, overflow errors etc)
Lecture 10: Data Transfer using I/O Structure / Assist. Prof. Dr. Hadeel N. Abdullah 18
8086 Interrupt Processing
If an interrupt has been requested, the 8086 Microprocessor processes it by performing the
following series of steps:
1. Pushes the content of the flag register onto the stack to preserve the status of the interrupt (IF)
and trap flags (TF), by decrementing the stack pointer (SP) by 2
2. Disables the INTR interrupt by clearing IF in the flag register
3. Resets TF in the flag register, to disable the single step or trap interrupt
4. Pushes the content of the code segment (CS) register onto the stack by decrementing SP by 2
5. Pushes the content of the instruction pointer (IP) onto the stack by decrementing SP by 2
6. Performs an indirect far jump to the start of the interrupt service routine (ISR) corresponding to
the received interrupt.
Lecture 10: Data Transfer using I/O Structure / Assist. Prof. Dr. Hadeel N. Abdullah 20
Non-Maskable Interrupt (NMI)
There are some interrupts which cannot be masked out or ignored by the processor. These are
associated with highpriority tasks which cannot be ignored (like memory parity or bus faults). In general, most
processors support the Non-Maskable Interrupt (NMI). This interrupt has absolute priority, and when it
occurs, the processor will finish thecurrent memory cycle, then branch to a special routine written to handle
the interrupt request.
INTR
The INTR is a maskable interrupt because the microprocessor will be interrupted only if interrupts are
enabled using set interrupt flag instruction. It should not be enabled using clear interrupt Flag instruction.
The INTR interrupt is activated by an I/O port. If the interrupt is enabled and NMI is disabled, then the
microprocessor first completes the current execution and sends ‘0’ on INTA pin twice. The first ‘0’ means
INTA informs the external device to get ready and during the second ‘0’ the microprocessor receives the 8 bit,
say X, from the programmable interrupt controller.
21
View publication stats
Software Interrupts
Some instructions are inserted at the desired position into the program to create interrupts.
These interrupt instructions can be used to test the working of various interrupt handlers. It
includes: