Microprocessor Interfacing Course Overview
Microprocessor Interfacing Course Overview
EEE 0714-3106
Microprocessor &
Interfacing
Course Content
Edited By :
Abdul Hai Utsho
Lecturer
Dept of EEE, UGV
1
Basic Course Information:
2
Assessment Pattern
Bloom’s Mid Term (45) Assignment (15) Quiz (15) Attendance &
External
Category Marks
(out of 90)
Remember 05 05
Understand 05 05 05
Apply 10 05 15
Analyze 10
Evaluate 10
Create 05 05
3
Assessment Pattern
4
Course Learning Outcome (CLO’s):
5
Course Rationales:
6
Course Objectives:
7
Course Contents Summary
Serial Course Contents Hours
No
1 Microprocessor Introduction, Microprocessor based System, 10
Assembly Language, memory basic, 8085 basic, Block
diagram, registers, Demultiplexing, Flag Registers, Flags
8
COURSE PLAN MAPPED WITH CLO
Week Content of Course Teaching-Learning Assessment Corresponding
Strategy Strategy CLOs
1 Introduction to Microprocessors: Basic Lecture, Visual Quiz, Discussion CLO-1
concepts, microprocessor-based systems, Demonstration
history, and applications
3 8085 Instruction Set: Data transfer, Lecture, Assembly Problem Solving, CLO-2
arithmetic, logical, and branching Language Example Assignment
instructions
4 Demultiplexing and Flag Registers: Lecture, Circuit Quiz, Problem CLO-1
Understanding the operation of flag Demonstration Solving
registers and demultiplexing of
address/data bus
5 Basic Programs in 8085: Writing and Practical, Hands-On Lab Report, CLO-2
debugging simple programs using the Lab Assignment
8085-instruction set
6 Introduction to 8086: Block diagram, Lecture, Visual Aids, Quiz, Assignment CLO-1
registers, pin diagram, and working Demonstration
principle
9
COURSE PLAN MAPPED WITH CLO
Week Course Content Teaching- Assessment Correspond
Strategy Strategy ing CLOs
12
Week - 1
13
Basic Concepts of Microprocessors
• Differences between:
– Microcomputer – a computer with a
microprocessor as its CPU. Includes memory, I/O
etc.
– Microprocessor – silicon chip which includes
ALU, register circuits & control circuits
– Microcontroller – silicon chip which includes
microprocessor, memory & I/O in a single
package.
14
What is a Microprocessor?
• The word comes from the combination micro and
processor.
– Processor means a device that processes whatever. In
this context processor means a device that processes
numbers, specifically binary numbers, 0’s and 1’s.
• To process means to manipulate. It is a general term that
describes all manipulation. Again in this content, it means to
perform certain operations on the numbers that depend on the
microprocessor’s design.
15
What about micro?
• Micro is a new addition.
– In the late 1960’s, processors were built using discrete
elements.
• These devices performed the required operation, but were too
large and too slow.
16
Was there ever a “mini”-
processor?
• No.
– It went directly from discrete elements to a
single chip. However, comparing today’s
microprocessors to the ones built in the early
1970’s you find an extreme increase in the
amount of integration.
17
Definition of the Microprocessor
18
Definition (Contd.)
– Takes in: The data that the microprocessor
manipulates must come from somewhere.
• It comes from what is called “input devices”.
• These are devices that bring data into the system
from the outside world.
• These represent devices such as a keyboard, a
mouse, switches, and the like.
19
Definition (Contd.)
– Numbers: The microprocessor has a very narrow view on life. It
only understands binary numbers.
20
Definition (Contd.)
– Words, Bytes, etc.
• The earliest microprocessor (the Intel 8088 and Motorola’s
6800) recognized 8-bit words.
– They processed information 8-bits at a time. That’s why they are
called “8-bit processors”. They can handle large numbers, but in
order to process these numbers, they broke them into 8-bit pieces
and processed each group of 8-bits separately.
22
Definition (Contd.)
– Stored in memory:
• When a program is entered into a computer, it is
stored in memory. Then as the microprocessor starts
to execute the instructions, it brings the instructions
from memory one at a time.
23
A Microprocessor-based system
From the above description, we can draw the
following block diagram to represent a
microprocessor-based system:
Output
Input
Memory
24
Organization of a microprocessor-
based system
• Let’s expand the picture a bit.
I/O
ALU Register Input/ Output
Array
System Bus
Control
Memory
ROM RAM
25
Microprocessor Fifth Generation Pentium
Fourth Generation
During 1980s
Low power version of HMOS technology
(HCMOS)
Third Generation 32 bit processors
During 1978 Physical memory space 224 bytes = 16 Mb
HMOS technology Faster speed, Higher Virtual memory space 240 bytes = 1 Tb
packing density Floating point hardware
16 bit processors 40/ 48/ 64 pins Supports increased number of addressing
Easier to program modes
Dynamically relatable programs
Processor has multiply/ divide arithmetic Intel 80386
hardware
More powerful interrupt handling
capabilities
Second Generation
Flexible I/O port addressing
During 1973
NMOS technology Faster speed, Higher
Intel 8086 (16 bit processor) density, Compatible with TTL
4 / 8/ 16 bit processors 40 pins
First Generation Ability to address large memory spaces
Between 1971 – 1973 and I/O ports
PMOS technology, non compatible with TTL Greater number of levels of subroutine
4 bit processors 16 pins nesting
8 and 16 bit processors 40 pins Better interrupt handling capabilities
Due to limitations of pins, signals are 11
multiplexed Intel 8085 (8 bit processor) 26
Memory
• Memory stores information such as instructions
and data in binary format (0 and 1). It provides
this information to the microprocessor whenever
it is needed.
RAM 2 6000
Address Range of 2nd RAM Chip
8FFF
RAM 3 9000
Address Range of 3rd RAM Chip
A3FF
RAM 4 A400
F7FF
FFFF
28
Machine Language
• The number of bits that form the “word” of a
microprocessor is fixed for that particular
processor.
– These bits define a maximum number of combinations.
• For example an 8-bit microprocessor can have at most 28 = 256
different combinations.
30
The 8085 Machine Language
• The 8085 (from Intel) is an 8-bit microprocessor.
– The 8085 uses a total of 246 bit patterns to form its
instruction set.
– These 246 patterns represent only 74 instructions.
• The reason for the difference is that some (actually most)
instructions have multiple different formats.
31
Assembly Language
• Using the same example from before,
– 00111100 translates to 3C in hexadecimal (OPCODE)
– Its mnemonic is: “INR A”.
– INR stands for “increment register” and A is short for
accumulator.
32
8085 Microprocessor Architecture
33
Pin diagram
Power
Supply: +5 V
Frequency
Generator is
connected to
those pins
Input/Output/
Memory
Read
Write
Enable
Multiplexed
Address Data
Bus
Address
Bus
34
Architecture of Intel 8085 Microprocessor
35
• System Bus – wires connecting memory & I/O to
microprocessor
– Address Bus
• Unidirectional
• Identifying peripheral or memory location
– Data Bus
• Bidirectional
• Transferring data
– Control Bus
• Synchronization signals
• Timing signals
• Control signal
36
The ALU
• In addition to the arithmetic & logic circuits, the
ALU includes the accumulator, which is part of
every arithmetic & logic operation.
38
• Registers
– General Purpose Registers
• B, C, D, E, H & L (8 bit registers)
• Can be used singly
• Or can be used as 16 bit register pairs
– BC, DE, HL
• H & L can be used as a data pointer (holds memory
address) Accumulator Flags
39
Week - 3
40
• Flag Register
– 8 bit register – shows the status of the microprocessor before/after an
operation
– S (sign flag), Z (zero flag), AC (auxillary carry flag), P (parity flag) &
CY (carry flag)
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
– Sign Flag
• Used for indicating the sign of the data in the accumulator
• The sign flag is set if negative (1 – negative)
• The sign flag is reset if positive (0 –positive)
41
• Zero Flag
– Is set if result obtained after an operation is 0
– Is set following an increment or decrement operation of that register
10110011
+ 01001101
1 00000000
• Carry Flag
– Is set if there is a carry or borrow from arithmetic operation
42
• Auxillary Carry Flag
– Is set if there is a carry out of bit 3
• Parity Flag
– Is set if parity is even
– Is cleared if parity is odd
43
• The Program Counter (PC)
– This is a register that is used to control the sequencing
of the execution of instructions.
– This register always holds the address of the next
instruction.
– Since it holds an address, it must be 16 bits wide.
44
• The Stack pointer
– The stack pointer is also a 16-bit register that is
used to point into memory.
– The memory this register points to is a special
area called the stack.
– The stack is an area of memory used to hold
data that will be retreived soon.
– The stack is usually accessed in a Last In First
Out (LIFO) fashion.
45
Week - 4
46
Memory
Demultiplexing AD7-AD0
8085
A15-A8
ALE
Latch
AD7-AD0 A7- A 0
D7- D0
50
Demultiplexing AD7-AD0
– From the above description, it becomes obvious
that the AD7– AD0 lines are serving a dual purpose
and that they need to be demultiplexed to get all the
information.
– The high order bits of the address remain on the bus
for three clock periods. However, the low order bits
r ain for only on lo k p riod and t y would
be lost if they are not saved externally. Also, notice
that the low order bits of the address disappear
when they are needed most.
– To make sure we have the entire address for the full
three clock cycles, we will use an external latch
to save the value of AD7– AD0 when it is carrying
the address bits. We use the ALE signal to enable
this latch.
51
Demultiplexing the Bus AD7 – AD0
• The high order address is placed on the address bus and hold for 3 clk
periods,
• The low order address is lost after the first clk period, this address
needs to be hold however we need to use latch
• The address AD7 – AD0 is connected as inputs to the latch 74LS373.
• The ALE signal is connected to the enable (G) pin of the latch and the
OC – Output control – of the latch is grounded
52
53
How Does the Microprocessor
Work?
➢ Assume that a program and data are already entered in the
R/W memory.
➢ The microprocessor fetches the first instruction from its
memory sheet, decodes it, and executes that instruction.
➢ The sequence of fetch, decode, and execute is continued
until the microprocessor comes across an instruction to stop.
➢ During the entire process, the microprocessor uses the
system bus to fetch the binary instructions and data from the
memory.
➢ It uses registers from the register section to store data
temporarily, and it performs the computing function in the
ALU section.
➢ Finally, it sends out the result in binary, using the same
bus lines, to memory or an output device. 4
54
How Does a Microprocessor Differentiate Between Data
and Instruction Code?
The microprocessor interprets the first byte it Mnemonics Hex Memory
Code Address
fetches as an opcode. In the example, we tell the
processor that our program begins at location MVI A, 3E 2000H
2000H. The first code it fetches is 3EH. When it 32H 32 2001H
decodes that code, it knows that it is a two-byte MVI 06 2002H
instruction. Therefore, it assumes that the second B,48H 48 2003H
code, 32H, is a data byte. If we forget to enter 32H
and enter the next code, 06H, instead, the 8085 will ADD B 80 2004H
load 06H in the accumulator, interpret the next
code, 48H, as an opcode, and continue the
execution in sequence. As a consequence, we may
encounter a totally unexpected result.
5
55
Week - 5
56
PROGRAM
Example: Write a program to perform 16 bit addition of
1234H & 4321H. Store answer at H & L registers.
MVI B, 21H B=21H
MVI A, 34H A=34H
MVI C, 43H C=43H
MVI D, 12H D=12H
ADD B A=34+21H
MOV L, A L=55H
MOV A, C A=43H
ADC D A=43+12H
MOV H, A H=55H
HLT STOP.
57
PROGRAM
Example:Write a program to exchange contents of
memory location D000H to D001H
16
58
PROGRAM
Write a program to reset last 4 bits of the number 32H
Store result at C200H.
MVI A, 32H A=32H
ANI F0H 00110010 AND
1111000
STA C200H C200=30H
RST1 Stop
59
PROGRAM
Write a program to add 10 data bytes. Data is stored from
locations C200H. Store result at C300H.
LXI H,C200H
MVI C, 0AH
MVI A,00H
UP MOV B,M
ADD B
INX H
DCR C
JNZ UP
STA C300H
RST1
60
8086 Features
• 16-bit Arithmetic Logic Unit
61
Week - 6
62
Pinouts
63
8086 Pins
The 8086 comes in a 40 pin package which means that some pins have
more than one use or are multiplexed. The packaging technology of time
limited the number of pin that could be used.
In particular, the address lines 0 - 15 are multiplexed with data lines 0-15,
address lines 16-19 are multiplexed with status lines. These pins are
The 8086 has one other pin that is multiplexed and this is BHE’/S7.
BHE stands for Bus High Enable. This is an active low signal that is
asserted when there is data on the upper half of the data bus.
The 8086 has two modes of operation that changes the function of some pins.
The SDK-86 uses the 8086 in the minimum mode with the MN/MX’ pin tied to 5
volts. This is a simple single processor mode. To work in maximum mode, the
MN/MX’ pin is tied to ground. This is the mode required for a coprocessor like
the 8087.
64
8086 Pins
In the minimum mode the following pins are available.
HOLD When this pin is high, another master is requesting control of the
local bus, e.g., a DMA controller.
65
8086 Block Diagram
66
8086 Architecture
• The 8086 has two parts, the Bus Interface Unit (BIU) and the
Execution Unit (EU).
• The BIU fetches instructions, reads and writes data, and computes the
20-bit address.
• The EU decodes and executes the instructions using the 16-bit ALU.
IP - Instruction Pointer
CS - Code Segment Register
DS - Data Segment Register
SS - Stack Segment Register
ES - Extra Segment Register
The BIU fetches instructions using the CS and IP, written CS:IP, to contruct the
20-bit address. Data is fetched using a segment register (usually the DS) and
an effective address (EA) computed by the EU depending on the addressing
mode.
67
8086 Architecture
The EU contains the following 16-bit registers:
AX – Accumulator
BX - Base Register
CX - Count Register
DX - Data Register
SP - Stack Pointer \ defaults to stack segment
BP - Base Pointer /
SI - Source Index Register
DI - Destination Register
The AX, BX, CX, and DX registers can be considers as two 8-bit registers, a
High byte and a Low byte. This allows byte operations and compatibility with
the previous generation of 8-bit processors, the 8080 and 8085. 8085 source
code could be translated in 8086 code and assembled. The 8-bit registers are:
AX --> AH,AL
BX --> BH,BL
CX --> CH,CL
DX --> DH,DL
I-11
68
Execution Unit (EU)
Auxiliary Carry Flag Carry Flag
Flag Register This flag is set, when there is
This flag is set, when there is a carry
out of low-nibble in case of addition or a carry out of MSB in case of
a borrow in case of subtraction addition or a borrow in case
of subtraction.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF DF IF TF SF ZF AF PF CF
Trap Flag
If this flag is set, the processor
Over flow Flag
enters the single step execution
mode by generating internal
The overflow flag is set to 1 when the result of a signed operation
is too large to fit.
interrupts after the execution of
each instruction
69
8086 Microprocessor Architecture
70
8086 Microprocessor
Architecture
Bus Interface Unit (BIU)
71
Memory Address Calculation
❑Segment addresses must be stored in
segment registers
❑Offset is derived from the combination of
pointer registers, the Instruction Pointer Segment address 0000
Memory address
❑ Examples
CS 3 4 8 A 0 SS 5 0 0 0 0
IP + 4 2 1 4 SP + F F E 0
Instruction address 3 8 A B 4 Stack address 5 F F E 0
DS 1 2 3 4 0
DI + 0 0 2 2
Data address 1 2 3 6 2
72
8086 Microprocessor
Architecture
Bus Interface Unit (BIU)
Segment
Registers
73
8086 Microprocessor
Architecture
Bus Interface Unit (BIU)
74
Architecture
8086 Microprocessor
Bus Interface Unit (BIU)
75
Week - 7
76
8086 Microprocessor
Architecture
Bus Interface Unit (BIU)
77
8086 Microprocessor
Architecture
Bus Interface Unit (BIU)
78
Architecture
8086 Microprocessor
Bus Interface Unit (BIU)
Instruction queue
A group of First-In-First-
Out (FIFO) in which up to
6 bytes of instruction
code are pre fetched from
the memory ahead of
time.
80
8086 Microprocessor
Architecture Execution Unit (EU)
EU decodes and
executes instructions.
A decoder in the EU
control system
translates instructions.
and
Some of the 16 bit registers can be
Index registers (Source used as two 8 bit registers as :
Index, Destination Index)
each of 16-bits AX can be used as AH and AL
BX can be used as BH and BL
CX can be used as CH and CL 8
DX can be used as DH and DL
81
8086 Microprocessor
Architecture
Execution Unit (EU)
84
Addressing
8086 Microprocessor
Modes
Every instruction of a program has to operate on a data.
The different ways in which a source operand is denoted
in an instruction are known as addressing modes.
1. Register Addressing
Group I : Addressing modes for
2. Immediate Addressing register and immediate data
3. Direct Addressing
5. Based Addressing
Group II : Addressing modes for
6. Indexed Addressing memory data
7. Based Index Addressing
8. String Addressing
85
8086 Microprocessor Group I : Addressing modes for
Addressing Modes register and immediate data
8. String Addressing
16
8086 Microprocessor Group I : Addressing modes for
Addressing Modes register and immediate data
1. Register Addressing
In immediate addressing mode, an 8-bit or 16-bit
2. Immediate Addressing data is specified as part of the instruction
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV DL, 08H
5. Based Addressing
The 8-bit data (08H) given in the instruction is
6. Indexed Addressing moved to DL
8. String Addressing
MOV AX, 0A9FH
9. Direct I/O port Addressing
The 16-bit data (0A9FH) given in the instruction is
10. Indirect I/O port Addressing moved to AX register
11. Relative Addressing
(AX) → 0A9FH
12. Implied Addressing
17
Addressing
8086 Microprocessor Group II : Addressing modes
Modes for memory data
1. Register Addressing
2. Immediate Addressing
Here, the effective address of the memory
3. Direct Addressing
location at which the data operand is stored is
4. Register Indirect Addressing given in the instruction.
9. Direct I/O port Addressing The square brackets around the 1354H denotes
the contents of the memory location. When
10. Indirect I/O port Addressing
executed, this instruction will copy the contents of
11. Relative Addressing the memory location into BX register.
12. Implied Addressing This addressing mode is called direct because the
displacement of the operand from the segment
base is specified directly in the instruction.
18
8086 Microprocessor
Addressing
Group II : Addressing modes
(CL) → (MA)
(CH) → (MA +1)
19
Week - 9
90
8086 Microprocessor
Instruction Set
8086 supports 6 types of instructions.
2. Arithmetic Instructions
3. Logical Instructions
91
8086 Microprocessor
Instruction Set
1. Data Transfer Instructions
10
92
8086 Microprocessor Instruction Set
1. Data Transfer Instructions
12
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
ADD A, data
13
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
ADDC A, data
14
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
SUB A, data
15
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
SBB A, data
16
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
17
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
Doesn't change the value of the register. result is not stored anywhere
CMP reg2/mem, reg1/ mem
21
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
22
8086 Microprocessor Instruction Set
2. Arithmetic Instructions
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
CMP A, data
23
Week - 10
102
8086 Microprocessor Instruction Set
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, ROL …
24
8086 Microprocessor Instruction Set
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, ROL …
25
8086 Microprocessor
Instruction Set
3. Logical Instructions
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, ROL …
26
Basic Interfacing Concept
107
INTERFACING IN MEMORY
MAPPED I/O
A15
A14 D0 D0
A13 D7 D7 PA0
A12 A0 A0 PA7
A11 A1 A1
A10 PB0
MEMR RD
A9
MEMW WR PB7
A8
A7 RESET OUT RESET
A6 PC0
A5
A4
8255 PC7
A3 CS
A2
108
8255 PPI
• The INTEL 8255 is a 40 pin IC having total 24 I/O
pins. consisting of 3 numbers of 8 –bit parallel I/O
ports (i.e. PORT A, PORT B,PORT C). The ports can
be programmed to function either as a input port or
as a output port in different operating modes. It
requires 4 internal addresses and has one logic LOW
chip select pin. Its main functions are to interface
peripheral devices to the microprocessor. Basically
used for parallel data transfer. operates in mainly
two modes.
• (1) Bit Set Reset Mode (BSR Mode).
• (2) I/O Mode.
109
Week - 11
110
Block Diagram of 8255 PPI
POWER +5V PA
SUPPLIES Ground GROUP A
GROUP A
PORT A (8)
CONTROL PA7-PA0
Bidirectional
Data Bus
D7- D0 GROUP A PCU
DATA BUS
BUFFER PORT C
8 Bit UPPER (4) PC7-PC4
Internal
Data Bus
GROUP B PCL
PORT C
LOWER (4) PC3-PC0
READ/
RD
WR WRITE
GROUP B PB
A0 CONTROL GROUP B
A1
LOGIC CONTROL
RESET PORT B (8)
PB7-PB0
cs 111
Function of Blocks
BLOCK FUNCTION OF BLOCK
8255 Pin
Diagram
113
Function of Pins
PIN FUNCTION OF PIN
These are bidirectional, tri-state data bus lines are connected to the
system data bus. They are used to transfer data and control word
D0-D7 (Data Bus) from microprocessor (8085) to 8255 or receive data or status word
from 8255 to the 8085.
These are 8 Bit bidirectional I/O pins used to send data to output
device and to receive data from input device. It functions as an 8 Bit
PA0-PA7 (Port A) data output latch/buffer when used in output mode and as an 8 Bit
data input latch/buffer when used in input mode.
These are 8 Bit bidirectional I/O pins used to send data to output
device and to receive data from input device. It functions as an 8 Bit
PB0-PB7 (Port B) data output latch/buffer when used in output mode and as an 8 Bit
data input latch/buffer when used in input mode.
114
Function of Pins
PIN FUNCTION OF PIN
These are 8 bit bidirectional I/O pins divided into two groups PCL
(PC3-PC) and PCU (PC7-PC4).these groups can individually transfer
PC0-PC7 data in or out when programmed for simple I/O, and used as
(Port C) handshake signals when programmed for handshake or
bidirectional modes.
When this pin is low, the CPU can read data in the ports or the
RD status word through the data bus buffer.
When this pin is low, the CPU can write data on the ports or in the
WR control register through the data bus buffer.
This pin can be enabled for data transfer operation between the CPU
CS and 8255.
This pin is used to reset 8255.i.e control register gets cleared and
RESET all the ports are set to the input mode.
115
Operating Modes Of 8255
• There are two main operational modes of 8255:
(1) Input/output mode,
(2) Bit set/reset mode (BSR Mode).
116
MODE 0
• In this mode, the ports can be used for simple input/output
operations without handshaking.
• If both port A and B are initialized in mode 0, the two halves
of port C can be either used together as an additional 8-bit
port, or they can be used as individual 4-bit ports.
• Since the two halves of port C are independent, they may be
used such that one-half is initialized as an input port while the
other half is initialized as an output port.
119
Week - 12
120
Control Word Format in I/O Mode
0 D6 D5 D4 D3 D2 D1 D0 GROUP B
PORT C (LOWER)
1=I/P, 0=O/P
PORT B
1=I/P, 0=O/P
MODE SELECTION
0 = MODE 0
1 = MODE 1
GROUP A
PORT C (UPPER)
1=I/P, 0=O/P
PORT A
1=I/P, 0=O/P
MODE SELECTION
00 = MODE 0
MODE SET FLAG 01 = MODE 1
1 = ACTIVE 1X = MODE 2
121
Control Word Format in BSR Mode
0 D6 D5 D4 D3 D2 D1 D0
BIT SET/RESET
1 = SET
2 = RESET
DON’T CARE
BIT SELECT
0 1 2 3 4 5 6 7
0 1 0 1 0 1 0 1 B0
0 0 1 1 0 0 1 1 B1
0 0 0 0 1 1 1 1 B2
• Solution:
1 0 0 1 1 0 0 0
= 98H
Program:
MVI A,98H ; LOAD CONTROL WORD
123
Write a program to initialize 8255 in the configuration
below.(assume address of the CW register as 23H).
(1) Port A: output with handshake
(2) Port B: input with handshake
(3) Port CL: output (4)Port CU: input
• Solution:
1 0 1 0 1 1 1 0
= AEH
Program:
MVI A,AEH ; LOAD CONTROL WORD
124
Find the control word for the register arrangement
of the ports of intel 8255 for mode 0 operation.
• Port A: Output, Port B: Output,
• Port CU: Output, Port CL: Output
Solution:
1 0 0 0 0 0 0 0
= 80H
Solution:
1 0 0 1 1 0 1 1
= 9BH
127
8259 Programmable Interrupt Controller (PIC)
1. This IC is designed to simplify the implementation of the interrupt interface in the 8088
and 8086 based microcomputer systems.
2. This device is known as a ‘Programmable Interrupt Controller’ or PIC.
3. It is manufactured using the NMOS technology and It is available in 28-pin DIP.
4. The operation of the PIC is programmable under software control (Programmable)and it
can be configured for a wide variety of applications.
5. 8259A is treated as peripheral in a microcomputer system.
6. 8259A PIC adds eight vectored priority encoded interrupts to the microprocessor.
7. This controller can be expanded without additional hardware to accept up to 64
interrupt request inputs. This expansion required a master 8259A and eight 8259A
slaves.
❖ When the 8259A is in buffered mode, this pin is an output that controls the data bus
transceivers in a large microprocessor-based system.
❖ When the 8259A is not in buffered mode, this pin programs the device as a master
(1) or a slave (0).
❖ CAS2-CAS0, the cascade lines are used as outputs from the master to the slaves for
cascading multiple 8259As in a system. 1304
8259A PIC- PIN DIGRAM
8
2
5
9
8259A PIC- BLOCK DIAGRAM
Week - 14
134
Slave 8259A
Interrupt controller
External e device 00
IR0
……..…
……..…
INT
Master 8259A
Interrupt controller
INTR
…………………
IR0
……..…
INT INT
IR7
Slave 8259A
Interrupt controller
……..…
INT
148
Programming the 8259A: -
The 82C59A accepts two types of command words generated by the
CPU:
1. Initialization Command Words (ICWs):
Before normal operation can begin, each 82C59A in the
system must be brought to a starting point - by a sequence of 2 to
4 bytes timed by WR pulses.
2. Operational Command Words (OCWs):
These are the command words which command the 82C59A
to operate in various interrupt modes. Among these modes are:
a. Fully nested mode.
b. Rotating priority mode.
c. Special mask mode.
d. Polled mode.
The OCWs can be written into the 82C59A anytime after
initialization.
Initialization Command Words: -
There are four Initialization
Command Words for the 8259A that are
selected with the help of logic level of A0
pin.
When the 8259A is first powered
up, it must be sent ICW1, ICW2 and ICW4.
If the 8259A is programmed in
cascade mode by ICW1, then we also
must program ICW3.
So, if a single 8259A is used in a
system ICW1, ICW2 and ICW4 must be
programmed.
If cascade mode is used in a
system, then all four ICWs must be
programmed.
BASICS OF SERIAL COMMUNICATION
& USART
153
AGENDA
Data Transmission Types
Parallel VS Serial
Synchronous VS Asynchronous
USART
WHY DO WE NEED FAST INTERFACES?
TX RX
2. Half duplex:
- Communication is possible in both directions,
but only one TX and one RX at a time. Ex. Police radio.
TX/RX TX/RX
Week - 16
159
DATA TRANSMISSION TYPES
3. Full duplex:
- Communication is possible in both directions,
both sides can transmit and receive in the same time.
TX/RX TX/RX
PARALLEL COMMUNICATION
The process of sending several bits as a
whole, on a link with several parallel
channels.
Clock skew Slowing up the data rate Not an issue for asynchronous
communication
1. Transmitter:
- A parallel-in, serial-out
shift register
2. Receiver:
- A serial-in, parallel-out
shift register.
171
SYNCHRONOUS VS ASYNCHRONOUS
1. Synchronous transmission:
Rx
Tx
Rx Tx
Clk
1. Asynchronous transmission:
Rx
Tx
Rx Tx
SYNCHRONOUS VS ASYNCHRONOUS
- In synchronous transmission, a separate link is dedicated for the
clock from one terminal (Master) to another (Slave).
- Both the transmitter and receiver use the same baud rate.
- When the transmitter pauses because it does not have data to transmit (idle
state), it keeps a sequence of stop bits (logic high) in its output.
Over speed clock (x16 baud rate)
Universal Synchronous
Asynchronous Receiver
Transmitter
(USART)
USART
- It contains all shift registers, clock generators and data buffers needed for
serial communication.
- The USART uses two I/O pins to transmit and receive serial data. Both
transmission and reception can occur at the same time i.e. ‘full duplex’
operation.
USART
- To send a byte, the application writes the byte to the transmit buffer.
- The UART then sends the data, bit by bit in the requested format,
adding Stop, Start, and parity bits as needed.
2. Data to be sent should be written into the TXREG register. When using 9-
bit, TX9D must be written before writing TXREG.
3. Byte will be immediately transferred to the shift register TSR after the STOP
bit from the pervious load is sent.
4. From there, data will be clocked out onto the TX pin preceded by a START
bit and followed by a STOP bit.
RECEIVER
1. The clock of the receiver is a multiple of the bit rate, in PIC 16f877A,it’s x16
or x64.
So, each bit is transmitted/received in 16 clock cycle.
2. If the receiver detects a start bit for a period= bit period (16 clock cycles),
then it waits for the period of half bit, and then sample the value on the RX
pin and shift it in the receiving shift register.
RECEIVER
3. Every received bit is sampled at the middle of the bit’s time period.
4. The USART can be configured to receive eight or nine bits by the RX9 bit
in the RCSTA register.
5. After the detection of a START bit, eight or nine bits of serial data are
shifted from the RX pin into the Receive Shift Register, one bit at a time.
6. After the last bit has been shifted in, the STOP bit is checked and the data
is moved into the FIFO buffer.