MPMC Notes
MPMC Notes
ON
MICROPROCESSORS AND
MICROCONTROLLERS
UNIT-1
Introduction to 8 bit microprocessor
Fundamentals for Microprocessor
Computer is of two types based on processing of information.
➢ Analog computer
➢ Digital computer
Examples: Keyboard, Mouse, Scanner, Microphone, Bar Code Reader, Optical Mark Reader
(OMR) etc
Memory: Memory is a storage device which is used to store programs, datas and results.
Output Device: Output devices are used to display the results according to the
instruction given to the computers.
Examples- Monitors, projectors, speakers, headphones and printers etc.
What is a microcomputer?
A digital computer in which one microprocessor has been provided to act as a CPU is called as
microcomputer.
What is a microprocessor?
➢ When the central processing unit is fabricated on a single IC is called as microprocessor.
➢ Micro means very small, as the processor is very small in size so it is called as
microprocessor.
Examples: 4004µP, 8085µP, 8086µP, 80286µP, 80386µP, 80486µP, Pentium etc.
Units of memory
➢ The smallest unit of memory is bit which can store the binary digits 0 or 1.
➢ The combination of 4 bits is called as 1 nibble.
➢ The combination of 8 bits is called as 1 Byte=2 nibble.
➢ 1 KB=210Bytes=1024 bits
➢ 1MB=220 Bytes=210KB=1024 KB
➢ 1GB=230Bytes=210MB=220KB
➢ 1TB=240Bytes=210GB=220MB=230KB
Evolution of microprocessors
➢ The first microprocessor was developed by Intel corporation in the year of 1971 and its
name is Intel 4004
➢ It is a 4bit microprocessor i.e the word length/word size is 4 bit.
➢ It is fabricated using p-MOS technology.
Opcodes and operands:
➢ Each instruction has two parts i.e operation code (opcode) and operands.
➢ Opcode specifies the task to be performed
➢ Operand is the data in which the operation is performed.
➢ Operand can be of 8-bit or 16 bit data, 8bit or 16 bit address, resisters etc.
Example:
Here MVI is the opcode and A and 45H are the operands.
What is a Bus?
➢ Bus is a group of conducting wires which carries information.
➢ All the peripherals are connected to microprocessor through Bus.
Types of Bus
There are three buses in a microprocessor as shown in the figure.
(i)Address Bus
(ii)Data Bus
(iii)Control Bus
Address Bus:-
➢ It is a group of conducting wires which carries address only.
➢ Address bus is unidirectional because data flow in one direction, from microprocessor to
memory or from microprocessor to Input/output devices.
➢ Length of Address Bus of 8085 microprocessor is 16 Bit (That is, Four Hexadecimal Digits),
ranging from 0000 H to FFFF H, (H denotes Hexadecimal). The microprocessor 8085 can transfer
maximum 16 bit address which means it can address 65, 536 different memory location.
Data Bus:-
Control Bus:-
➢ It is a group of conducting wires, which is used to generate timing and control signals to
control all the associated peripherals,
➢ Some control signals are:
• Memory read
• Memory write
• I/O read
• I/O Write
• Opcode fetch
(c)Registers
(d)Serial Input Output Control unit
As the name suggests, it performs arithmetic and logical operations like Addition, Subtraction, logical
AND, logical OR, etc. on 8-bit data.
It generates timing and control signals which are necessary for the microprocessor to perform
operations. Following are the timing and control signals, which control external and internal
circuits.
(c)Registers:
Registers are used by the microprocessor to store datas and instructions temporarily. So it is a
temporarily storage device.
Program counter
Temporary register
It is an 8-bit register which is not available to the programmer, but It is used by the
microprocessor internally for execution of some operations.
It is an 8-bit register. When an instruction is fetched from memory then it is stored in the
Instruction register. Instruction decoder decodes the information present in the Instruction
register.
Flag register/Program Status word (PSW):
➢ It is an 8-bit register having five 1-bit flip-flops, which holds either 0 or 1 depending
upon the result stored in the accumulator.
➢ These are the set of 5 status flags.
1. Sign (S)
2. Zero (Z)
4. Parity (P)
5. Carry (C)
All of the status flags are set or reset according to the stored result in the accumulator or register A.
1. Sign(S)-This flag is used to know whether the number is positive or negative after the ALU
operation.
➢ If B7 of the result is 1 then sign flag is set, So the number is negative.
➢ If B7 of the result is 0 then sign flag is reset, So the number is positive.
Example:
2. Zeros (Z)-If the result after the ALU operation is zero then this flag is set otherwise it is reset.
Example:
3. Auxiliary carry(AC)-During the ALU operation if a carry is generated from B3 to B4 bit then this
flag is set otherwise reset.
Example:
4. Parity (P)-
➢ If the result stored in the accumulator after the ALU operation contains even number of
1’s then this flag is set
➢ If the result stored in the accumulator after the ALU operation contains odd number of
1’s then this flag is reset
Example:
5. Carry(C)-
During the ALU operation if a carry is generated from B7 to B8 bit then this flag is set otherwise
reset.
Example:
There are two pins in this unit. This unit is used for serial data communication.
➢ Data bus carries the data to be stored. It is bidirectional and length is 8 bit.
➢ Address bus carries the location to where it should be stored. It is unidirectional and
length is 16 bit
Instruction word Size
The computer or microprocessor is able to understand the instructions which are written in the
binary form or machine code form. But the length of all the instructions is not same. According
to the length, the instructions are divided in 3 types
1 Byte instructions
In the 1 Byte instructions, only the instruction code or opcode is present which specifies that
the operation performed by the microprocessesor as well as the register present.
2 Byte instructions
In the 2 Byte instructions, the 8 bit data is present in the instruction itself.
3 Byte instructions
In the 3 Byte instructions, the 16 bit address is present in the instruction itself.
Immediate Addressing:
In this mode, the operand given in the instruction - a byte or word – transfers to the destination
register or memory location.
Ex: MVI A, 9AH
➢ The operand is a part of the instruction.
➢ The operand is stored in the register mentioned in the instruction.
Direct Addressing:
Memory direct addressing moves a byte or word between a memory location and register. The
memory location address is given in the instruction.
Ex: LDA 850FH
➢ This instruction is used to load the content of memory address 850FH in the accumulator.
Register Direct Addressing:
Register direct addressing transfer a copy of a byte or word from source register to destination
register.
Ex: MOV B, C
It copies the content of register C to register B.
Register Indirect Addressing:
Indirect addressing transfers a byte or word between a register and a memory location.
Ex: MOV A, M
➢ Here the data is in the memory location pointed to by the contents of HL pair. The data is
moved to the accumulator.
Implicit Addressing
Implicit Addressing In this addressing mode the data itself specifies the data to be operated upon.
Ex: CMA
➢ The instruction complements the content of the accumulator. No specific data or operand
is mentioned in the instruction.
SIGNAL DESCRIPTIONS/PIN CONFIGURATION OF 8085 MICROPROCESSOR
➢ 8085 is a 40 pin IC, The signals from the pins can be grouped as follows
Vcc:+5voltpowersupply
Vss:Ground
X1,X2 : It is used to set the frequency of internal clock generator. Since the basic operating
timing frequency is 3 MHz.
CLK (output)-Clock Output is used as the system clock for peripheral and devices interfaced
with the microprocessor.
2. Address Bus
A8 - A15:
It carries the most significant 8 bits(higher 8 bit ) of the memory address or the 8 bits of the
I/O address.
3. Data bus
AD0 - AD7
4. Control Signals
RD (READ)
WR (WRITE)
➢ Write memory or IO device.
➢ This indicates that the data on the data bus is to be written into the selected
memory location or I/O device.
➢ This signal indicates that the read / write operation relates to whether the memory
or I/O device.
➢ If this signal goes HIGH then the operation is an I/O operation.
➢ If this signal goes LOW then the operation is an I/O operation.
5. Status Signals:
SL NO S1 S0 OPERATION
1 0 0 HLT
2 0 1 WRITE
3 1 0 READ
4 1 1 FETCH
Interrupt signals
TRAP
RST 7.5
RST 6.5
RST 5.5
INTA
➢ They are the signals initiated by an external device to request the microprocessor to do a
particular task or work.
➢ On receipt of an interrupt, the microprocessor acknowledges the interrupt by the INTA
(Interrupt Acknowledge) signal.
7. Reset Signals:
Reset In
➢ This signal is used to reset the microprocessor.
➢ The program counter inside the microprocessor is set to zero.
Reset Out
➢ It indicates CPU is being reset.
➢ Used to reset all the connected devices when the microprocessor is reset.
➢ When two or more devices are connected to a common bus, to prevent the devices from
interfering with each other, the tristate gates are used to disconnect all devices except the one
that is communicating at a given instant.
➢ Direct Memory Access(DMA) operation is used for large volume data transfer between memory
and an I/O device directly.
HOLD
➢ HOLD signal is generated by the DMA controller circuit. It indicates that another device is
requesting to use the address and data bus
HLDA
➢ It is a signal which indicates that the hold request has been received.
READY
➢ This signal indicates that the device is ready to send or receive data.
Types of Interrupts
Interrupt are classified into following groups based on their parameter −
• Vector interrupt − In this type of interrupt, the interrupt address is known to the
processor.
• Non-Vector interrupt − In this type of interrupt, the interrupt address is not known to
the processor so, the interrupt address require to send externally by the device to perform
interrupts.
• Maskableinterrupt − In this type of interrupt, you can neglect the interrupt by giving
some instructions to the program.
• Softwareinterrupt−
➢ The software interrupts can be treated as CALL instructions with default call
locations.
➢ Software interrupt is special kind of interrupt which programmer can use as an
instruction.
➢ There are 8 software interrupts in 8085.
• Hardware interrupt –
Note − INTA is not an interrupt, it is used by the microprocessor for sending acknowledgement.
TRAP has the highest priority, then RST7.5 and so on.
TRAP
It is called as a non-maskable interrupt, which has the highest priority among all interrupts. It is
subroutine calls which are forced by the microprocessor when it identifies any interruption in the
instructions. Bydefault, it is enabled until it gets acknowledged. So, when the power failure
occurs, it executes as ISR and sends the data to backup memory. This interrupt transfers the
control to the location 0024H.
RST7.5
It is called as maskable interrupt, which has the second highest priority among all interrupts.
When this interrupt is executed, the processor saves the content of the PC register into the stack
and branches to 003CH address.
RST 6.5
It is a maskable interrupt, having the third highest priority among all interrupts. When this
interrupt is executed, the processor saves the content of the PC register into the stack and
branches to 0034H address.
RST 5.5
It is a maskable interrupt. When this interrupt is executed, the processor saves the content of the
PC register into the stack and branches to 002CH address.
INTR
It is a maskable interrupt, having the lowest priority among all interrupts. It can be deleted by
resetting the microprocessor.
When INTR signal goes high, the following events can occur −
• The status of INTR signal is being checked by the microprocessor during the execution of
each instruction.
• When the INTR signal is high, then the microprocessor finishes its current instruction and
sends active low interrupt acknowledge signal.
• When instructions are received, then the microprocessor saves the address of the next
instruction on stack and the received instruction is executed.
➢ The stack is a Last in Fast out (LIFO) structure i.e the element which will be inserted last
in to the stack will be removed first.
➢ The stack normally grows backwards into memory.i.e the programmer defines the bottom
of the stack and the stack grows up into reducing address range
➢ The starting memory location (Stack top) of the stack is defined in the main program.
➢ The stack pointer is defined by the following instruction
LXI SP, 4700H
Here: 4700H is the stack top address.
Instructions related to stack:
The programmer can perform the operation on the stack using the following two instructions.
PUSH: It is used to put data on to the stack
POP: It is used to get data from stack
Syntax of PUSH Instruction:
PUSH rp
Here rp:is the register pair
Comments: The content of specified register pair is inserted or pushed on to the stack.
Example:
LXI SP 4799H
LXI H 4257H
PUSH H
When instruction PUSH H is executed, the following sequence of data transfer takes
place.
1. The stack pointer is decremented by one to 4798H and the content of the higher byte of
register pair (H) is copied in to the stack memory location 4798H.
2. The stack pointer register is again decremented by one to 4797H and the content of the
lower byte of register pair is copied in to the stack memory location 4797H.
Timing Diagram
Instruction Cycle:
T-State:
✓ The machine cycle and instruction cycle takes multiple clock periods.
✓ A portion of an operation carried out in one system clock period is called as
T-state.
The 8085 microprocessor has 5 (seven) basic machine cycles. They are
✓ The memory read machine cycle is executed by the processor to read a data
byte from memory.
✓ The processor takes 3T states to execute this cycle.
The instructions which have more than one byte word size will use the machine
cycle after the opcode fetch machine cycle.
Cycle 3. Memory Write Machine Cycle of 8085
✓ The memory write machine cycle is executed by the processor to write a data
byte in a memory location.
✓ The processor takes, 3T states to execute this machine cycle.
✓ The I/O Read cycle is executed by the processor to read a data byte from I/O
port or from the peripheral, which is I/O, mapped in the system.
✓ The processor takes 3T states to execute this machine cycle.
✓ The IN instruction uses this machine cycle during the execution.
✓ Fetching the Opcode 34H from the memory 4105H. (OF cycle)
✓ Let the memory address (M) be 4250H. (MR cycle -To read Memory address
and data)
✓ Let the content of that memory is 12H.
✓ Increment the memory content from 12H to 13H. (MW machine cycle)
UNIT-2
Advanced Microprocessor
Features of 8086
8086 Microprocessor is an enhanced version of 8085Microprocessor that was
designed by Intel in 1976.
It is a 16-bit Microprocessor i.e it is having 16 number of data lines.
It has 20 address lines So the maximum memory capacity is 1MB.
It consists of powerful instruction set, which provides operations like multiplication
and division easily.
It supports two modes of operation, i.e. Maximum mode and Minimum mode.
Maximum mode is suitable for system having multiple processors and Minimum
mode is suitable for system having a single processor.
It has an instruction queue, which is capable of storing six instruction bytes from
the memory resulting in faster processing.
It uses two stages of pipelining, i.e. Fetch Stage and Execute Stage, which improves
performance.
Fetch stage can prefetch up to 6 bytes of instructions and stores them in the queue
and Execute stage executes these instructions.
It has 256 vectored interrupts.
It consists of 29,000 transistors.
8086 Architecture
EU (Execution Unit)
Sending addresses,
Fetching instructions from the memory,
Reading data from the ports and the memory as well as writing data
to the ports and the memory.
EU has no direction connection with System Buses so this is possible with the BIU.
EU and BIU are connected with the Internal Bus.
Register Organization of 8086
General purpose register
There are 8 general purpose registers, i.e., AH, AL, BH, BL, CH, CL, DH, and DL.
These registers can be used individually to store 8-bit data .
Two 8-bit registers are used to make a register pair which can store 16-bit data.
The valid register pairs in 8086 microprocessor are AX, BX, CX, and DX
respectively.
AX register –
BX register
CX register –
It is referred to as counter.
It is of 16 bits and is divided into two 8-bit registers CH and CL
It is used in loop instruction to store the loop counter.
DX register –
It is a 16-bit register.
It is used to hold the address of the stack top.
It is a 16-bit register
It is primary used in accessing parameters passed by the stack
It is a 16-bit register
It is used in the pointer addressing of data and as a source in some string related
operations.
It is a 16-bit register
It is used in the pointer addressing of data and as a destination in some string
related operations.
Flag Register
It is a 16-bit register.
This register is used to store the status of the result after any arithmetic operations.
It has 9 flags and they are divided into 2 groups − Conditional Flags and Control
Flags.
Conditional Flags
It represents the result of the last arithmetic or logical instruction executed. Following is
the list of conditional flags −
Carry flag − This flag indicates an overflow condition for arithmetic operations.
Auxiliary flag − When an operation is performed at ALU, it results in a
carry/barrow from lower nibble (i.e. D0 – D3) to upper nibble (i.e. D4 – D7), then
this flag is set, i.e. carry given by D3 bit to D4 is AF flag. The processor uses this flag
to perform binary to BCD conversion.
Parity flag − This flag is used to indicate the parity of the result, i.e. when the lower
order 8-bits of the result contains even number of 1’s, then the Parity Flag is set. For
odd number of 1’s, the Parity Flag is reset.
Zero flag − This flag is set to 1 when the result of arithmetic or logical operation is
zero else it is set to 0.
Sign flag − This flag holds the sign of the result, i.e. when the result of the operation
is negative, then the sign flag is set to 1 else set to 0.
Overflow flag – T his flag represents the result when the system
capacity is exceeded.
Control Flags
Control flags controls the operations of the execution unit. Following is the list of control
flags −
Trap flag − It is used for single step control and allows the user to execute one
instruction at a time for debugging. If it is set, then the program can be run in a
single step mode.
Interrupt flag − It is an interrupt enable/disable flag, i.e. used to allow/prohibit the
interruption of a program. It is set to 1 for interrupt enabled condition and set to 0
for interrupt disabled condition.
Direction flag − It is used in string operation. As the name suggests when it is set
then string bytes are accessed from the higher memory address to the lower
memory address and vice-a-versa.
Memory Segmentation and Physical memory organization in
8086 microprocessor
What is memory segmentation?
Memory Segmentation is the process in which the main memory of the computer is logically
divided into different segments and each segment has its own base address.
It is basically used to enhance the speed of execution of the computer system.
Due to segmentation the processor is able to fetch and execute the data from the memory
easily and fast.
8086 microprocessor has a 20-bit address bus so it can address a maximum of 1MB
of memory.
8086 can work with only four 64 KB segments at a time within this 1MB range.
These four memory segments are called as code segment, data segment, and Extra
segment and stack segment.
The Bus Interface Unit (BIU) contains four 16 bit special purpose registers called as
Segment registers .The segment registers are named as
Code segment register
Data segment register
Extra Segment Register
Stack Segment Register
The segment registers are used to hold the upper 16 bits from the 20-bit physical
address in the respective segments.
Calculation of Physical address:
The 16-bit content of one of the four segment registers (CS, DS, ES, SS) is known as
the base segment address
The offset address is the distance or displacement from the base segment address to
the next address within the segments. The offset address is also called as logical
address
Generally offset address is contained in the registers IP, BP, SP, BX, SI or DI
depending on the segments used.
Offset and base segment address are combined to form a 20-bit physical address
(also called real address) that is used to access the memory.
The content of the segment register is internally appended with 0H (0000B) on its
right most end to form a 20-bit memory address—this 20-bit address points to the
start of the segment. The offset is then added to the above to get the physical
address.
The formula to calculate the 20-bit physical address is
Example-1
If the DS is 4247 H and offset is A95C H then calculate the
(i) Starting address of the segment
(ii) End address of the segment
(iii) Operands 20-bit physical address.
Example:
MOV CL, 12H This instruction moves the data 12H to CL register
MOV AH, 37H This instruction moves the data 37H to AH register
MOV AX, 4567H This instruction moves the data 4567H to AX register
In this mode, operands are specified using registers. Registers are used for both
source and destination operands .
Example:
In this mode, the offset address of the operand is directly specified in the instruction
itself. The 20-bit physical address for the operand can be calculated adding the
offset address with the default segment DS or ES.
Example:
This instruction moves data from the offset address 5358H into register AL
The physical address is calculated as
DS * 10H + 5358H
Assume DS = 5000H
So AL ← [55358H]
In this addressing mode the operands offset address is hold by the registers. The 20-
bit physical address for the operand can be calculated adding the offset address with
the default segment DS or ES.
Example:
This instruction moves the data from the address pointed by BX into register.
In this mode, the operands 20-bit physical address is calculated by adding the 8 bit
or a 16 bit displacement along with the offset address within the default segments
DS or ES .
Example:
This instruction moves one byte data from the address pointed by BX + 25H in data
segment to AL.
In this addressing mode, the index registers are used to hold the offset address. The
Source index (SI) register and Destination Index(DI) registers are used in this
addressing mode.
Examples:
In this addressing mode the base registers (BX or BP) and the indexed registers(SI
or DI) are used to hold the offset address.
Example:
In this addressing mode the base registers (BX or BP) and the indexed registers (SI
or DI) along with a 8 bit or a 16 bit displacement are used to hold the offset address.
Example:
Example:
STC
8086 was the first 16-bit microprocessor available in 40-pin DIP (Dual Inline
Package) chip
Power supply and frequency signals
It uses 5V DC supply at VCC pin 40, and uses ground at VSS pin 1 and 20 for its
operation.
Clock signal
Clock signal is provided through Pin-19. It provides timing to the processor for
operations. Its frequency is different for different versions, i.e. 5MHz, 8MHz and
10MHz.
Address/data bus
AD0-AD15. These are 16 address/data bus. AD0-AD7 carries low order byte data
and AD8-AD15 carries higher order byte data. During the first clock cycle, it carries
16-bit address and after that it carries 16-bit data.
Address/status bus
A16-A19/S3-S6. These are the 4 address/status buses. During the first clock cycle, it
carries 4-bit address and later it carries status signals.
S7/BHE
BHE stands for Bus High Enable. It is available at pin 34 and used to indicate the
transfer of data using data bus D8-D15. This signal is low during the first clock
cycle, thereafter it is active.
Read
Ready
It is available at pin 22. It is an acknowledgement signal from I/O devices that data
is transferred. It is an active high signal. When it is high, it indicates that the device
is ready to transfer data. When it is low, it indicates wait state
RESET
It is available at pin 21 and is used to restart the execution. It causes the processor to
immediately terminate its present activity. This signal is active high for the first 4
clock cycles to RESET the microprocessor.
INTR
NMI
INTA
ALE
It stands for address enable latch and is available at pin 25. A positive pulse is
generated each time the processor begins any operation. This signal indicates the
availability of a valid address on the address/data lines.
HLDA
It stands for Hold Acknowledgement signal and is available at pin 30. This signal
acknowledges the HOLD signal.
HOLD
This signal indicates to the processor that external devices are requesting to access
the address/data buses. It is available at pin 31.
LOCK
When this signal is active, it indicates to the other processors not to ask the CPU to leave
the system bus. It is activated using the LOCK prefix on any instruction and is available at
pin 29.
Instruction set and Assembly language
programming of 8086 microprocessor:
The instructions of 8086 microprocessor are classified in the following category
3.Branch/Loop instructions
6. Interrupt Instructions
These instructions are used to transfer the data from the source to the destination.
Examples:
PUSH AX
XCHG AX, BX
Comments:It transfer the operand from the port address to the accumulator.
Examples:
IN AX,0028H
OUT port address, accumulator
Comments:It transfer the operand from the accumulator to the port address.
Examples:
OUT 0028H,AX
Comment: These instructions add a number from some source to a number in some
destination and put the result in the specified destination.
Example:
ADD AX, BX: Add content of BX to content of AX and result in AX
ADD AL, 74H: Add immediate number 74H to content of AL and Result is stored in AL
Comments: These instructions subtract the number in some source from the number in
some destination and put the result in the destination
Examples:
SUB CX, BX Subtract BX from CX and result stored in CX
SUB AX, 3427H Subtract immediate number 3427H from AX and result stored in AX
MUL source
Comments: This instruction is used for multiplication.
DIV source
Comments: This instruction is used for division.
3.Branch/Loop instructions
These instructions are used to transfer the control during an execution with some conditions
4.Machine/Processor Control Instructions
The additional circuitry converts the status signals (S 2-S0) into the I/O and
memory transfer signals. It also generates the control signals required to
direct the data flow and for controlling 8282 latches and 8286 transceivers.
the 8288 is able to originate the address latch enable signal to the 8282’s,
the enable and direction signals to the 8286 transceivers, and the interrupt
acknowledge signal to the interrupt controller.
UNIT-3
Programmable Peripheral Interface (8255)
The 8255A is a general purpose programmable I/O device designed to transfer the
data from I/O to interrupt I/O under certain conditions as required. It can be used with
almost any microprocessor.
It consists of three 8-bit bidirectional I/O ports (24I/O lines) which can be configured as
per the requirement.
Ports of 8255A
8255A has three ports, i.e., PORT A, PORT B, and PORT C.
Port A contains one 8-bit output latch/buffer and one 8-bit input buffer.
Port B is similar to PORT A.
Port C can be split into two parts, i.e. PORT C lower (PC0-PC3) and PORT C
upper (PC7-PC4) by the control word.
These three ports are further divided into two groups, i.e. Group A includes PORT A
and upper PORT C. Group B includes PORT B and lower PORT C. These two groups
can be programmed in three different modes, i.e. the first mode is named as mode 0,
the second mode is named as Mode 1 and the third mode is named as Mode 2.
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.
Features of 8255A
The prominent features of 8255A are as follows −
It consists of 3 8-bit IO ports i.e. PA, PB, and PC.
Address/data bus must be externally demux'd.
It is TTL compatible.
It has improved DC driving capability.
8255 Architecture
The following figure shows the architecture of 8255A −
Let us first take a look at the pin diagram of Intel 8255A −
CS
It stands for 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.
Their result depends on the following conditions −
CS A1 A0 Result
0 0 0 PORT A
0 0 1 PORT B
0 1 0 PORT C
0 1 1 Control Register
1 X X No Selection
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.
A0 and A1
These input signals work with RD, WR, and one of the control signal. Following is the
table showing their various signals with their result.
A1 A0 RD WR CS Result
0 0 0 1 0 Input Operation
PORT A → Data Bus
Output Operation
0 0 1 0 0
Data Bus → PORT A
0 1 1 0 0 Data Bus → PORT A
Features of 8253 / 54
The most prominent features of 8253/54 are as follows −
It has three independent 16-bit down counters.
It can handle inputs from DC to 10 MHz.
These three counters can be programmed for either binary or BCD count.
It is compatible with almost all microprocessors.
8254 has a powerful command called READ BACK command, which allows the
user to check the count value, the programmed mode, the current mode, and
the current status of the counter.
8254 Architecture
The architecture of 8254 looks as follows −
8254 Pin Description
Here is the pin diagram of 8254 −
In the above figure, there are three counters, a data bus buffer, Read/Write control
logic, and a control register. Each counter has two input signals - CLOCK & GATE, and
one output signal - OUT.
Data Bus Buffer
It is a tri-state, bi-directional, 8-bit buffer, which is used to interface the 8253/54 to the
system data bus. It has three basic functions −
Read/Write Logic
It includes 5 signals, i.e. RD, WR, CS, and the address lines A 0 & A1. In the peripheral
I/O mode, the RD and WR signals are connected to IOR and IOW, respectively. In the
memorymapped I/O mode, these are connected to MEMR and MEMW.
Address lines A0 & A1 of the CPU are connected to lines A0 and A1 of the 8253/54, and
CS is tied to a decoded address. The control word register and counters are selected
according to the signals on lines A0 & A1.
A1 A0 Result
0 0 Counter 0
0 1 Counter 1
1 0 Counter 2
X X No Selection
A1 A0 RD WR CS Result
0 0 1 0 0 Write Counter 0
0 1 1 0 0 Write Counter 1
1 0 1 0 0 Write Counter 2
0 0 0 1 0 Read Counter 0
0 1 0 1 0 Read Counter 1
1 0 0 1 0 Read Counter 2
1 1 0 1 0 No operation
X X 1 1 0 No operation
X X X X 1 No operation
Counters
Each counter consists of a single, 16 bit-down counter, which can be operated in either
binary or BCD. Its input and output is configured by the selection of modes stored in
the control word register. The programmer can read the contents of any of the three
counters without disturbing the actual count in process.
Data Bus Buffer This block is used to communicate between 8259 and 8085/8086
by acting as buffer. It takes the control word from 8085/8086 and
send it to the 8259. It transfers the opcode of the selected
interrupts and address of ISR to the other connected
microprocessor. It can send maximum 8-bit at a time.
R/W Control Logic This block works when the value of pin CS is 0. This block is used
to flow the data depending upon the inputs of RD and WR. These
are active low pins for read and write.
Block Description
Control Logic It controls the functionality of each block. It has pin called INTR.
This is connected to other microprocessors for taking the interrupt
request. The INT pin is used to give the output. If 8259 is enabled,
and also the interrupt flags of other microprocessors are high then
this causes the value of the output INT pin high, and in this way
this chip can responds requests made by other microprocessors.
Interrupt Request It stores all interrupt level that are requesting for interrupt service.
Register
Interrupt Service It stores interrupt level that are currently being execute.
Register
Interrupt Mask It stores interrupt level that will be masked, by storing the masking
Register bits of interrupt level.
Priority Resolver It checks all three registers, and set the priority of the interrupts.
Interrupt with the highest priority is set in the ISR register. It also
reset the interrupt level which is already been serviced in the IRR.
Features of 8257
Here is a list of some of the prominent features of 8257 −
It has four channels which can be used over four I/O devices.
Each channel has 16-bit address and 14-bit counter.
Each channel can transfer data up to 64kb.
Each channel can be programmed independently.
Each channel can perform read transfer, write transfer and verify transfer
operations.
It generates MARK signal to the peripheral device that 128 bytes have been
transferred.
It requires a single phase clock.
Its frequency ranges from 250Hz to 3MHz.
It operates in 2 modes, i.e., Master mode and Slave mode.
8257 Architecture
The following image shows the architecture of 8257 −
8257 Pin Description
The following image shows the pin diagram of a 8257 DMA controller −
DRQ0−DRQ3
These are the four individual channel DMA request inputs, which are used by the
peripheral devices for using DMA services. When the fixed priority mode is selected,
then DRQ0 has the highest priority and DRQ3 has the lowest priority among them.
DACKo − DACK3
These are the active-low DMA acknowledge lines, which updates the requesting
peripheral about the status of their request by the CPU. These lines can also act as
strobe lines for the requesting devices.
Do − D7
These are bidirectional, data lines which are used to interface the system bus with the
internal data bus of DMA controller. In the Slave mode, it carries command words to
8257 and status word from 8257. In the master mode, these lines are used to send
higher byte of the generated address to the latch. This address is further latched using
ADSTB signal.
IOR
It is an active-low bidirectional tri-state input line, which is used by the CPU to read
internal registers of 8257 in the Slave mode. In the master mode, it is used to read data
from the peripheral devices during a memory write cycle.
IOW
It is an active low bi-direction tri-state line, which is used to load the contents of the
data bus to the 8-bit mode register or upper/lower byte of a 16-bit DMA address
register or terminal count register. In the master mode, it is used to load the data to the
peripheral devices during DMA memory read cycle.
CLK
It is a clock frequency signal which is required for the internal operation of 8257.
RESET
This signal is used to RESET the DMA controller by disabling all the DMA channels.
Ao - A 3
These are the four least significant address lines. In the slave mode, they act as an
input, which selects one of the registers to be read or written. In the master mode, they
are the four least significant memory address output lines generated by 8257.
CS
It is an active-low chip select line. In the Slave mode, it enables the read/write
operations to/from 8257. In the master mode, it disables the read/write operations
to/from 8257.
A4 - A 7
These are the higher nibble of the lower byte address generated by DMA in the master
mode.
READY
It is an active-high asynchronous input signal, which makes DMA ready by inserting
wait states.
HRQ
This signal is used to receive the hold request signal from the output device. In the
slave mode, it is connected with a DRQ input line 8257. In Master mode, it is
connected with HOLD input of the CPU.
HLDA
It is the hold acknowledgement signal which indicates the DMA controller that the bus
has been granted to the requesting peripheral by the CPU when it is set to 1.
MEMR
It is the low memory read signal, which is used to read the data from the addressed
memory locations during DMA read cycles.
MEMW
It is the active-low three state signal which is used to write the data to the addressed
memory location during DMA write operation.
ADST
This signal is used to convert the higher byte of the memory address generated by the
DMA controller into the latches.
AEN
This signal is used to disable the address bus/data bus.
TC
It stands for ‘Terminal Count’, which indicates the present DMA cycle to the present
peripheral devices.
MARK
The mark will be activated after each 128 cycles or integral multiples of it from the
beginning. It indicates the current DMA cycle is the 128th cycle since the previous
MARK output to the selected peripheral device.
Vcc
It is the power signal which is required for the operation of the circuit.
The Keyboard can be interfaced either in the interrupt or the polled mode. In
the Interrupt mode, the processor is requested service only if any key is pressed,
otherwise the CPU will continue with its main task.
In the Polled mode, the CPU periodically reads an internal flag of 8279 to check
whether any key is pressed or not with key pressure.
The keyboard consists of maximum 64 keys, which are interfaced with the CPU
by using the key-codes. These key-codes are de-bounced and stored in an 8-byte
FIFORAM, which can be accessed by the CPU. If more than 8 characters are
entered in the FIFO, then it means more than eight keys are pressed at a time. This
is when the overrun status is set.
If a FIFO contains a valid key entry, then the CPU is interrupted in an interrupt
mode else the CPU checks the status in polling to read the entry. Once the CPU
reads a key entry, then FIFO is updated, and the key entry is pushed out of the
FIFO to generate space for new entries.
Architecture and Description