Microprocessor Tutorial
Microprocessor Tutorial
In this tutorial, we will discuss the architecture, pin diagram and other key concepts of
microprocessors.
Audience
This tutorial is designed for all those readers pursing either Bachelors or Masters degree
in Computer Science. It will help them understand the basic concepts related to
Microprocessors.
Prerequisites
In this tutorial, all the topics have been explained from elementary level. Therefore, a
beginner can understand this tutorial very easily. However if you have a prior knowledge
of computer architecture in general, then it will be quite easy to grasp the concepts
explained here.
All the content and graphics published in this e-book are the property of Tutorials Point (I)
Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish
any contents or a part of contents of this e-book in any manner without written consent
of the publisher.
We strive to update the contents of our website and tutorials as timely and as precisely as
possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt.
Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our
website or its contents including this tutorial. If you discover any errors on our website or
in this tutorial, please notify us at contact@tutorialspoint.com.
i
Microprocessors
Table of Contents
About the Tutorial ............................................................................................................................................ i
Audience ........................................................................................................................................................... i
Prerequisites ..................................................................................................................................................... i
Disclaimer & Copyright ..................................................................................................................................... i
Table of Contents ............................................................................................................................................ ii
MICROPROCESSOR...................................................................................................................... 1
3. 8085 Architecture................................................................................................................................. 10
8085 Microprocessor Functional Units ....................................................................................................... 10
8085 Architecture .......................................................................................................................................... 12
ii
Microprocessors
MICROCONTROLLERS................................................................................................................ 76
iii
Microprocessors
iv
Microprocessors
Microprocessor
1
1. Microprocessor Overview Microprocessors
Microprocessor consists of an ALU, register array, and a control unit. ALU performs
arithmetical and logical operations on the data received from the memory or an input
device. Register array consists of registers identified by letters like B, C, D, E, H, L and
accumulator. The control unit controls the flow of data and instructions within the
computer.
Microprocessor
Input Output
Device (ALU +Register array + Device
Control unit)
Memory
Initially, the instructions are stored in the memory in a sequential order. The
microprocessor fetches those instructions from the memory, then decodes it and executes
those instructions till STOP instruction is reached. Later, it sends the result in binary to
the output port. Between these processes, the register stores the temporarily data and
ALU performs the computing functions.
2
Microprocessors
Clock Speed: It determines the number of operations per second the processor
can perform. It is expressed in megahertz (MHz) or gigahertz (GHz).It is also known
as Clock Rate.
Word Length: It depends upon the width of internal data bus, registers, ALU, etc.
An 8-bit microprocessor can process 8-bit data at a time. The word length ranges
from 4 bits to 64 bits depending upon the type of the microcomputer.
Data Types: The microprocessor has multiple data type formats like binary, BCD,
ASCII, signed and unsigned numbers.
Features of a Microprocessor
Here is a list of some of the most prominent features of any microprocessor:
Cost-effective: The microprocessor chips are available at low prices and results
its low cost.
Versatility: The microprocessors are versatile as we can use the same chip in a
number of applications by configuring the software program.
3
2. Microprocessor Classification Microprocessors
RISC Processor
RISC stands for Reduced Instruction Set Computer. It is designed to reduce the
execution time by simplifying the instruction set of the computer. Using RISC processors,
each instruction requires only one clock cycle to execute results in uniform execution time.
This reduces the efficiency as there are more lines of code, hence more RAM is needed to
store the instructions. The compiler also has to work more to convert high-level language
instructions into machine code.
4
Microprocessors
Architecture of RISC
RISC microprocessor architecture uses highly-optimized set of instructions. It is used in
portable devices like Apple iPod due to its power efficiency.
Instruction
Data cache
cache
(Instruction)
+ (Data)
Main memory
Characteristics of RISC
The major characteristics of a RISC processor are as follows:
5
Microprocessors
CISC Processor
CISC stands for Complex Instruction Set Computer. It is designed to minimize the
number of instructions per program, ignoring the number of cycles per instruction. The
emphasis is on building complex instructions directly into the hardware.
The compiler has to do very little work to translate a high-level language into assembly
level language/machine code because the length of the code is relatively short, so very
little RAM is required to store the instructions.
IBM 370/168
VAX 11/780
Intel 80486
Architecture of CISC
Its architecture is designed to decrease the memory cost because more storage is needed
in larger programs resulting in higher memory cost. To resolve this, the number of
instructions per program can be reduced by embedding the number of operations in a
single instruction.
Characteristics of CISC
Variety of addressing modes.
Larger number of instructions.
Variable length of instruction formats.
Several cycles may be required to execute one instruction.
Instruction-decoding logic is complex.
One instruction is required to support multiple addressing modes.
6
Microprocessors
Special Processors
These are the processors which are designed for some special purposes. Few of the special
processors are briefly discussed:
Coprocessor
A coprocessor is a specially designed microprocessor, which can handle its particular
function many times faster than the ordinary microprocessor.
Input/Output Processor
It is a specially designed microprocessor having a local memory of its own, which is used
to control I/O devices with minimum CPU involvement.
For example:
For example:16-bit T212, 32-bit T425, the floating point (T800, T805 & T9000)
processors.
7
Microprocessors
Program Memory: It stores the programs that DSP will use to process data.
For example: Texas Instruments TMS 320 series, e.g., TMS 320C40, TMS320C50.
8
Microprocessors
8085 Microprocessor
9
3. 8085 Architecture Microprocessors
Accumulator
It is an 8-bit register used to perform arithmetic, logical, I/O & LOAD/STORE operations.
It is connected to internal data bus & ALU.
Program counter
It is a 16-bit register used to store the memory address location of the next instruction to
be executed. Microprocessor increments the program whenever an instruction is being
executed, so that the program counter points to the memory address of the
next instruction that is going to be executed.
Stack pointer
It is also a 16-bit register works like stack, which is always incremented/decremented by
2 during push & pop operations.
10
Microprocessors
Temporary register
It is an 8-bit register, which holds the temporary data of arithmetic and logical operations.
Flag register
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.
Sign (S)
Zero (Z)
Auxiliary Carry (AC)
Parity (P)
Carry (C)
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
Interrupt control
As the name suggests it controls the interrupts during a process. When a microprocessor
is executing a main program and whenever an interrupt occurs, the microprocessor shifts
the control from the main program to process the incoming request. After the request is
completed, the control goes back to the main program.
There are 5 interrupt signals in 8085 microprocessor: INTR, RST 7.5, RST 6.5, RST 5.5,
TRAP.
11
Microprocessors
8085 Architecture
We have tried to depict the architecture of 8085 with this following image:
12
4. 8085 Pin Configuration Microprocessors
Address bus
A15-A8, it carries the most significant 8-bits of memory/IO address.
Data bus
AD7-AD0, it carries the least significant 8-bit address and data bus.
13
Microprocessors
RD: This signal indicates that the selected IO or memory device is to be read and
is ready for accepting data available on the data bus.
WR: This signal indicates that the data on the data bus is to be written into a
selected memory or IO location.
ALE: It is a positive going pulse generated when a new operation is started by the
microprocessor. When the pulse goes high, it indicates address. When the pulse
goes down it indicates data.
IO/M
This signal is used to differentiate between IO and Memory operations, i.e. when it is high
indicates IO operation and when it is low then it indicates memory operation.
S1 & S0
These signals are used to identify the type of current operation.
Power supply
There are 2 power supply signals: VCC & VSS. VCC indicates +5v power supply and VSS
indicates ground signal.
Clock signals
There are 3 clock signals, i.e. X1, X2, CLK OUT.
X1, X2: A crystal (RC, LC N/W) is connected at these two pins and is used to set
frequency of the internal clock generator. This frequency is internally divided by 2.
CLK OUT: This signal is used as the system clock for devices connected with the
microprocessor.
RESET IN: This signal is used to reset the microprocessor by setting the program
counter to zero.
14
Microprocessors
RESET OUT: This signal is used to reset all the connected devices when the
microprocessor is reset.
READY: This signal indicates that the device is ready to send or receive data. If
READY is low, then the CPU has to wait for READY to go high.
HOLD: This signal indicates that another master is requesting the use of the
address and data buses.
HLDA (HOLD Acknowledge): It indicates that the CPU has received the HOLD
request and it will relinquish the bus in the next clock cycle. HLDA is set to low
after the HOLD signal is removed.
SOD (Serial output data line): The output SOD is set/reset as specified by the SIM
instruction.
SID (Serial input data line): The data on this line is loaded into accumulator
whenever a RIM instruction is executed.
15
5. 8085 Addressing Modes & Interrupts
Microprocessors
Interrupts in 8085
Interrupts are the signals generated by the external devices to request the microprocessor
to perform a task. There are 5 interrupt signals, i.e. TRAP, RST 7.5, RST 6.5, RST 5.5, and
INTR.
Vector interrupt: In this type of interrupt, the interrupt address is known to the
processor. For example: RST7.5, RST6.5, RST5.5, TRAP.
Non-Vector interrupt: In this type of interrupt, the interrupt address is not known
to the processor so, the interrupt address needs to be sent externally by the device
to perform interrupts. For example: INTR.
16
Microprocessors
Software interrupt: In this type of interrupt, the programmer has to add the
instructions into the program to execute the interrupt. There are 8 software
interrupts in 8085, i.e. RST0, RST1, RST2, RST3, RST4, RST5, RST6, and RST7.
TRAP
It is a non-maskable interrupt, having the highest priority among all interrupts. Bydefault,
it is enabled until it gets acknowledged. In case of failure, it executes as ISR and sends
the data to backup memory. This interrupt transfers the control to the location 0024H.
RST7.5
It is a maskable interrupt, having 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
disabled by resetting the microprocessor.
17
Microprocessors
When INTR signal goes high, the following events can occur:
The microprocessor checks the status of INTR signal during the execution of each
instruction.
When the INTR signal is high, then the microprocessor completes 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 executes the received instruction.
18
6. 8085 Instruction Sets Microprocessors
Instruction sets are instruction codes to perform some task. It is classified into five
categories.
Control Instructions
Following is the table showing the list of control instructions with their meanings.
Logical Instructions
The following table shows the list of logical instructions with their meanings.
19
Microprocessors
R Exclusive OR
register or The contents of the accumulator are
XRA memory with the Exclusive OR with M the contents of the
M
accumulator register or memory, and the result is
placed in the accumulator.
Exclusive OR
immediate with The contents of the accumulator are
XRI 8-bit data
the accumulator Exclusive OR with the 8-bit data and the
result is placed in the accumulator.
R Logical OR
register or The contents of the accumulator are
ORA memory with the logically OR with M the contents of the
M
accumulator register or memory, and result is placed
in the accumulator.
20
Microprocessors
Branching Instructions
Following is the table showing the list of Branching instructions with their meanings.
The program
sequence is
16-bit Jump transferred to the
JMP memory address
address unconditionally
given in the
operand.
Flag
Opcode Description
Status The program
sequence is
JC Jump on Carry CY = 1
transferred to the
Jump on no 16-bit memory address
JNC CY = 0 Jump
Carry address given in the
conditionally
Jump on operand based on
JP S=0 the specified flag
positive
of the PSW.
JM Jump on minus S = 1
JZ Jump on zero Z=1
21
Microprocessors
Jump on no
JNZ Z=0
zero
Jump on parity
JPE P=1
even
Jump on parity
JPO P=0
odd
Flag
Opcode Description
Status
The program
CC Call on Carry CY = 1 sequence is
Call on no transferred to the
CNC CY = 0 memory address
Carry
given in the
CP Call on positive S = 0
16-bit Unconditional operand. Before
CM Call on minus S=1 address subroutine call transferring, the
address of the
CZ Call on zero Z=1
next instruction
CNZ Call on no zero Z = 0 after CALL is
Call on parity pushed onto the
CPE P=1 stack.
even
Call on parity
CPO P=0
odd
The program
sequence is
Return from transferred from
RET None subroutine the subroutine to
unconditionally the calling
program.
Flag
Opcode Description
Status The program
Return on sequence is
RC CY = 1 transferred from
Carry
the subroutine to
Return on no
RNC CY = 0 the calling
Carry Return from program based on
Return on None subroutine the specified flag
RP S=0 conditionally
positive of the PSW and
the program
Return on
RM S=1 execution begins
minus
at the new
RZ Return on zero Z=1 address.
Return on no
RNZ Z=0
zero
22
Microprocessors
Return on
RPE P=1
parity even
Return on
RPO P=0
parity odd
The contents of
registers H & L are
copied into the
Load the program counter.
program The contents of H
PCHL None are placed as the
counter with
HL contents high-order byte
and the contents
of L as the low-
order byte.
The RST
instruction is used
as software
instructions in a
program to
transfer the
program execution
to one of the
following eight
locations.
Restart
Instruction
Address
RST
RST 0 0000H
0-7 Restart
RST1 0008H
RST 2 0010H
RST 3 0018H
RST 4 0020H
RST 5 0028H
RST 6 0030H
RST 7 0038H
23
Microprocessors
Restart
Interrupt
Address
TRAP 0024H
Arithmetic Instructions
Following is the table showing the list of Arithmetic instructions with their meanings.
24
Microprocessors
Add the
The 8-bit data and the Carry flag are added to
immediate
8-bit the contents of the accumulator and the result is
ACI to the
data stored in the accumulator.
accumulator
with carry Example: ACI 55K.
Add the
register pair The 16-bit data of the specified register pair are
DAD Reg. pair to H and L added to the contents of the HL register.
registers Example: DAD K.
25
Microprocessors
Decrement
R the register The contents of the designated register or
or the memory are decremented by 1 and their result
DCR
M memory by is stored at the same place. Example: DCR K.
1
Example: DAA.
26
Microprocessors
Example: LDAX K
Reg. Load the The instruction loads 16-bit data in the register
pair, register pair pair designated in the register or the memory.
LXI
16-bit immediate
data Example: LXI K, 3225L
27
Microprocessors
Example: XCHG.
Example: SPHL.
Example: XTHL.
Example: PUSH K.
Example: POPK.
Output the
data from the The contents of the accumulator are copied into
8-bit
accumulator to the I/O port specified by the operand.
OUT port
address a port with 8-
Example: OUT K9L,
bit address
Problem demo:
(3005H) = 14H
(3006H) = 89H
30
Microprocessors
31
Microprocessors
8086 Microprocessor
32
7. 8086 Overview Microprocessors
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.
Features of 8086
The most prominent features of a 8086 microprocessor are as follows:
It has an instruction queue, which is capable of storing six instruction bytes from
the memory resulting in faster processing.
It was the first 16-bit processor having 16-bit ALU, 16-bit registers, internal data
bus, and 16-bit external data bus resulting in faster processing.
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.
Address Bus: 8085 has 16-bit address bus while 8086 has 20-bit address bus.
33
Microprocessors
I/O: 8085 can address 2^8 = 256 I/O's, whereas 8086 can access 2^16 = 65,536
I/O's.
Architecture of 8086
The following diagram depicts the architecture of a 8086 Microprocessor:
34
8. 8086 Functional Units Microprocessors
8086 Microprocessor is divided into two functional units, i.e., EU (Execution Unit) and BIU
(Bus Interface Unit).
EU (Execution Unit)
Execution unit gives instructions to BIU stating from where to fetch the data and then
decode and execute those instructions. Its function is to control operations on data using
the instruction decoder & ALU. EU has no direct connection with system buses as shown
in the above figure, it performs operations over data through BIU.
ALU
It handles all arithmetic and logical operations, like +,-,,/, OR, AND, NOT operations.
Flag Register
It is a 16-bit register that behaves like a flip-flop, i.e. it changes its status according to
the result stored in the accumulator. 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.
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 1s, then the Parity Flag is set.
For odd number of 1s, 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: This flag represents the result when the system capacity is
exceeded.
35
Microprocessors
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.
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.
DX register: This register is used to hold I/O port address for I/O instruction.
Instruction queue: BIU contains the instruction queue. BIU gets upto 6 bytes of
next instructions and stores them in the instruction queue. When EU executes
36
Microprocessors
instructions and is ready for its next instruction, then it simply reads the instruction
from this instruction queue resulting in increased execution speed.
Fetching the next instruction while the current instruction executes is called
pipelining.
Segment register: BIU has 4 segment buses, i.e. CS, DS, SS& ES. It holds the
addresses of instructions and data in memory, which are used by the processor to
access memory locations. It also contains 1 pointer register IP, which holds the
address of the next instruction to executed by the EU.
o CS: It stands for Code Segment. It is used for addressing a memory location
in the code segment of the memory, where the executable program is stored.
o DS: It stands for Data Segment. It consists of data used by the program
andis accessed in the data segment by an offset address or the content of
other register that holds the offset address.
o SS: It stands for Stack Segment. It handles memory to store data and
addresses during execution.
Instruction pointer: It is a 16-bit register used to hold the address of the next
instruction to be executed.
37
9. 8086 Pin Configuration Microprocessors
8086 was the first 16-bit microprocessor available in 40-pin DIP (Dual Inline Package)
chip. Let us now discuss in detail the pin configuration of a 8086 Microprocessor.
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 ()
It is available at pin 32 and is used to read signal for Read operation.
Ready
It is available at pin 32. 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
It is available at pin 18. It is an interrupt request signal, which is sampled during the last
clock cycle of each instruction to determine if the processor considered this as an interrupt
or not.
NMI
39
Microprocessors
It stands for non-maskable interrupt and is available at pin 17. It is an edge triggered
input, which causes an interrupt request to the microprocessor.
This signal is like wait state and is available at pin 23. When this signal is high, then the
processor has to wait for IDLE state, else the execution continues.
MN/
It stands for Minimum/Maximum and is available at pin 33. It indicates what mode the
processor is to operate in; when it is high, it works in the minimum mode and vice-a-
versa.
INTA
It is an interrupt acknowledgement signal and id available at pin 24. When the
microprocessor receives this signal, it acknowledges the interrupt.
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.
DEN
It stands for Data Enable and is available at pin 26. It is used to enable Transreceiver
8286. The transreceiver is a device used to separate data from the address/data bus.
DT/R
It stands for Data Transmit/Receive signal and is available at pin 27. It decides the
direction of data flow through the transreceiver. When it is high, data is transmitted out
and vice-a-versa.
M/IO
This signal is used to distinguish between memory and I/O operations. When it is high, it
indicates I/O operation and when it is low indicates the memory operation. It is available
at pin 28.
WR
It stands for write signal and is available at pin 29. It is used to write the data into the
memory or the output device depending on the status of M/IO signal.
HLDA
It stands for Hold Acknowledgement signal and is available at pin 30. This signal
acknowledges the HOLD signal.
HOLD
40
Microprocessors
This signal indicates to the processor that external devices are requesting to access the
address/data buses. It is available at pin 31.
QS1& QS0
These are queue status signals and are available at pin 24 and 25. These signals provide
the status of instruction queue. Their conditions are shown in the following table:
No operation
0 0
First byte of opcode from the queue
0 1
Empty the queue
1 0
Subsequent byte from the queue
1 1
S0, S1, S2
These are the status signals that provide the status of operation, which is used by the Bus
Controller 8288 to generate memory & I/O control signals. These are available at pin 26,
27, and 28. Following is the table showing their status:
S2 S1 S0 Status
0 0 0 Interrupt acknowledgement
0 0 1 I/O Read
0 1 0 I/O Write
0 1 1 Halt
1 0 0 Opcode fetch
1 0 1 Memory read
1 1 0 Memory write
1 1 1 Passive
41
Microprocessors
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.
RQ/GT1& RQ/GT0
These are the Request/Grant signals used by the other processors requesting the CPU to
release the system bus. When the signal is received by CPU, then it sends
acknowledgment. RQ/GT0 has a higher priority than RQ/GT1.
42
10. 8086 Instruction Sets Microprocessors
POP: Used to get a word from the top of the stack to the provided location.
43
Microprocessors
Arithmetic Instructions
These instructions are used to perform arithmetic operations like addition, subtraction,
multiplication, division, etc.
CWD: Used to fill the upper word of the double word with the sign bit of the lower
word.
AND: Used for adding each bit in a byte/word with the corresponding bit in another
byte/word.
OR: Used to multiply each bit in a byte/word with the corresponding bit in another
byte/word.
XOR: Used to perform Exclusive-OR operation over each bit in a byte/word with
the corresponding bit in another byte/word.
ROR: Used to rotate bits of byte/word towards the right, i.e. LSB to MSB and to
Carry Flag [CF].
RCR: Used to rotate bits of byte/word towards the right, i.e. LSB to CF and CF to
MSB.
45
Microprocessors
RCL: Used to rotate bits of byte/word towards the left, i.e. MSB to CF and CF to
LSB.
String Instructions
String is a group of bytes/words and their memory is always allocated in a sequential
order.
REPE/REPZ: Used to repeat the given instruction until CX=0 or zero flag ZF=1.
REPNE/REPNZ: Used to repeat the given instruction until CX=0 or zero flag ZF=1.
SCAS/SCASB/SCASW: Used to scan a string and compare its byte with a byte in
AL or string word with a word in AX.
LODS/LODSB/LODSW: Used to store the string byte into AL or string word into
AX.
CALL: Used to call a procedure and save their return address to the stack.
RET: Used to return from the procedure to the main program.
JMP: Used to jump to the provided address to proceed to the next instruction.
46
Microprocessors
JLE/JNG: Used to jump if less than/equal/if not greater than instruction satisfies.
LOOP: Used to loop a group of instructions until the condition satisfies, i.e., CX=0
47
Microprocessors
LOOPE/LOOPZ: Used to loop a group of instructions till it satisfies ZF=1 & CX=0
Interrupt Instructions
These instructions are used to call the interrupt during program execution.
INT: Used to interrupt the program during execution and calling service specified.
INTO: Used to interrupt the program during execution if OF=1
IRET: Used to return from interrupt service to the main program
48
11. 8086 Interrupts Microprocessors
Interrupt is the method of creating a temporary halt during program execution and allows
peripheral devices to access the microprocessor. The microprocessor responds to that
interrupt with an ISR (Interrupt Service Routine), which is a short program to instruct the
microprocessor on how to handle the interrupt.
The following image shows the types of interrupts we have in a 8086 microprocessor:
Interrupts
Hardware Software
Interrupt Interrupt
Hardware Interrupts
Hardware interrupt is caused by any peripheral device by sending a signal through a
specified pin to the microprocessor.
The 8086 has two hardware interrupt pins, i.e. NMI and INTR. NMI is a non-maskable
interrupt and INTR is a maskable interrupt having lower priority. One more interrupt pin
associated is INTA called interrupt acknowledge.
NMI
It is a single non-maskable interrupt pin (NMI) having higher priority than the maskable
interrupt request pin (INTR)and it is of type 2 interrupt.
Pushes the CS (code segment) value and IP (instruction pointer) value of the return
address on to the stack.
49
Microprocessors
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.
Flag register value, CS value of the return address and IP value of the return
address are pushed on to the stack.
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:
CS value of the return address and IP value of the return address are pushed on to
the stack.
50
Microprocessors
The starting address for type0 interrupt is 000000H, for type1 interrupt is 00004H similarly
for type2 is 00008H and so on. The first five pointers are dedicated interrupt pointers.
i.e.:
The interrupts from Type 5 to Type 31 are reserved for other advanced microprocessors,
and interrupts from 32 to Type 255 are available for hardware and software interrupts.
CS value of the return address and IP value of the return address are pushed on to
the stack.
51
Microprocessors
CS value of the return address and IP value of the return address are pushed on to
the stack.
52
12. 8086 Addressing Modes Microprocessors
MOV AX, [BX] ; Suppose the register BX contains 4895H, then the contents
; 4895H are moved to AX
ADD CX, {BX}
53
Microprocessors
54
Microprocessors
Multiprocessor Configuration
55
13. Multiprocessor Configuration Overview
Microprocessors
Coprocessor configuration
Closely coupled configuration
Loosely coupled configuration
Coprocessor Configuration
A Coprocessor is a specially designed circuit on microprocessor chip which can perform the
same task very quickly, which the microprocessor performs. It reduces the work load of
the main processor. The coprocessor shares the same memory, IO system, bus, control
logic and clock generator. The coprocessor handles specialized tasks like mathematical
calculations, graphical display on screen, etc.
The 8086 and 8088 can perform most of the operations but their instruction set is not able
to perform complex mathematical operations, so in these cases the microprocessor
requires the math coprocessor like Intel 8087 math coprocessor, which can easily perform
these operations very quickly.
The coprocessor and the processor is connected via TEST, RQ-/GT- and QS0 & QS1
signals.
The TEST signal is connected to BUSY pin of coprocessor and the remaining 3 pins
are connected to the coprocessors 3 pins of the same name.
TEST signal takes care of the coprocessors activity, i.e. the coprocessor is busy or
idle.
The coprocessor uses QS0 & QS1 to track the status of the queue of the host
processor.
None of the instructions are used for communication, like WAIT, ESC, etc.
The host processor manages the memory and wakes up the independent processor
by sending commands to one of its ports.
Then the independent processor accesses the memory to execute the task.
57
Microprocessors
Advantages
58
Microprocessors
Each of the processors have their own local bus to access the local memory/I/O
devices. This makes it easy to achieve parallel processing.
The system structure is flexible, i.e. the failure of one module doesnt affect the
whole system failure; faulty module can be replaced later.
59
14. 8087 Numeric Data Processor Microprocessors
8087 numeric data processor is also known as Math co-processor, Numeric processor
extension and Floating point unit. It was the first math coprocessor designed by Intel
to pair with 8086/8088 resulting in easier and faster calculation.
Once the instructions are identified by the 8086/8088 processor, then it is allotted to the
8087 co-processor for further execution.
Binary Integers
Packed decimal numbers
Real numbers
Temporary real format
The most prominent features of 8087 numeric data processor are as follows:
It supports data of type integer, float, and real types ranging from 2-10 bytes.
The processing speed is so high that it can calculate multiplication of two 64-bits
real numbers in ~27 s and can also calculate square-root in ~35 s.
8087 Architecture
8087 Architecture is divided into two groups, i.e., Control Unit (CU) and Numeric
Extension Unit (NEU).
The control unit handles all the communication between the processor and the
memory such as it receives and decodes instructions, reads and writes memory
operands, maintains parallel queue, etc. All the coprocessor instructions are ESC
instructions, i.e., they start with F, the coprocessor only executes the ESC
instructions while other instructions are executed by the microprocessor.
The numeric extension unit handles all the numeric processor instructions like
arithmetic, logical, transcendental, and data transfer instructions. It has 8 register
stack, which holds the operands for instructions and their results.
60
Microprocessors
AD0 AD15: These are the time multiplexed address/data lines, which carry
addresses during the first clock cycle and data from the second clock cycle
onwards.
61
Microprocessors
A19 / S6 A16/S: These lines are the time multiplexed address/status lines. It
functions in a similar way to the corresponding pins of 8086. The S 6, S4 and S3 are
permanently high, while the S5 is permanently low.
QS1, QS0: These are queue status input signals which provides the status of
instruction queue, their conditions as shown in the following table:
BUSY: It is an output signal, when it is high it indicates a busy state to the CPU.
READY: It is an input signal used to inform the coprocessor whether the bus is
ready to receive data or not.
RESET: It is an input signal used to reject the internal activities of the coprocessor
and prepare it for further execution whenever required by the CPU.
CLK: The CLK input provides the basic timings for the processor operation.
VCC: It is a power supply signal, which requires +5V supply for the operation of the
circuit.
S0, S1, S2: These are the status signals that provide the status of the operation
which is used by the Bus Controller 8087 to generate memory and I/O control
signals. These signals are active during the fourth clock cycle.
S2 S1 S0 Queue Status
0 X X Unused
1 0 0 Unused
1 0 1 Memory read
1 1 0 Memory write
1 1 1 Passive
RQ/GT1 & RQ/GT0: These are the Request/Grant signals used by the 8087
processors to gain control of the bus from the host processor 8086/8088 for
operand transfers.
62
Microprocessors
I/O Interfacing
63
15. I/O Interfacing Overview Microprocessors
In this chapter, we will discuss Memory Interfacing and IO Interfacing with 8085.
Interface is the path for communication between two components. Interfacing is of two
types, memory interfacing and I/O interfacing.
Memory Interfacing
When we are executing any instruction, we need the microprocessor to access the memory
for reading instruction codes and the data stored in the memory. For this, both the memory
and the microprocessor requires some signals to read from and write to registers.
The interfacing process includes some key factors to match with the memory requirements
and microprocessor signals. The interfacing circuit therefore should be designed in such a
way that it matches the memory signal requirements with the signals of the
microprocessor.
IO Interfacing
There are various communication devices like the keyboard, mouse, printer, etc. So, we
need to interface the keyboard and other devices with the microprocessor by using latches
and buffers. This type of interfacing is known as I/O interfacing.
64
Microprocessors
Serial Communication Interface: In this type of communication, the interface gets a single
byte of data from the microprocessor and sends it bit by bit to the other system serially
and vice-a-versa.
Parallel Communication Interface: In this type of communication, the interface gets a byte
of data from the microprocessor and sends it bit by bit to the other systems in
simultaneous (or) parallel fashion and vice-a-versa.
65
16. 8279 Programmable Keyboard Microprocessors
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.
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.
66
Microprocessors
Scan Counter
It has two modes i.e. Encoded mode and Decoded mode. In the encoded mode, the
counter provides the binary count that is to be externally decoded to provide the scan lines
for the keyboard and display.
In the decoded scan mode, the counter internally decodes the least significant 2 bits
and provides a decoded 1 out of 4 scan on SL0-SL3.
67
Microprocessors
In the scanned sensor matrix mode, this unit acts as sensor RAM where its each row is
loaded with the status of their corresponding row of sensors into the matrix. When the
sensor changes its state, the IRQ line changes to high and interrupts the CPU.
CLK
The clock input is used to generate internal timings required by the microprocessor.
RESET
As the name suggests this pin is used to reset the microprocessor.
CS Chip Select
When this pin is set to low, it allows read/write operations, else this pin should be set to
high.
A0
This pin indicates the transfer of command/status information. When it is low, it indicates
the transfer of data.
RD, WR
This Read/Write pin enables the data buffer to send/receive data over the data bus.
IRQ
This interrupt output line goes high when there is data in the FIFO sensor RAM. The
interrupt line goes low with each FIFO RAM read operation. However, if the FIFO RAM
further contains any key-code entry to be read by the CPU, this pin again goes high to
generate an interrupt to the CPU.
Vss, Vcc
These are the ground and power supply lines of the microprocessor.
SL0SL3
These are the scan lines used to scan the keyboard matrix and display the digits. These
lines can be programmed as encoded or decoded, using the mode control register.
RL0RL7
These are the Return Lines which are connected to one terminal of keys, while the other
terminal of the keys is connected to the decoded scan lines. These lines are set to 0 when
any key is pressed.
SHIFT
The Shift input line status is stored along with every key code in FIFO in the scanned
keyboard mode. Till it is pulled low with a key closure, it is pulled up internally to keep it
high.
69
Microprocessors
In the keyboard mode, this line is used as a control input and stored in FIFO on a key
closure. The line is a strobe line that enters the data into FIFO RAM, in the strobed input
mode. It has an internal pull up. The line is pulled down with a key closure.
BD
It stands for blank display. It is used to blank the display during digit switching.
Input Mode
This mode deals with the input given by the keyboard and this mode is further classified
into 3 modes.
Scanned Keyboard Mode: In this mode, the key matrix can be interfaced using
either encoded or decoded scans. In the encoded scan, an 8x8 keyboard or in the
decoded scan, a 4x8 keyboard can be interfaced. The code of key pressed with
SHIFT and CONTROL status is stored into the FIFO RAM.
Scanned Sensor Matrix: In this mode, a sensor array can be interfaced with the
processor using either encoder or decoder scans. In the encoder scan, 8x8 sensor
matrix or with decoder scan 4x8 sensor matrix can be interfaced.
Strobed Input: In this mode, when the control line is set to 0, the data on the
return lines is stored in the FIFO byte by byte.
Output Mode
This mode deals with display-related operations. This mode is further classified into two
output modes.
Display Entry: This mode allows the data to be entered for display either from the
right side/left side.
70
17. 8257 DMA Controller Microprocessors
DMA stands for Direct Memory Access. It is designed by Intel to transfer data at the fastest
rate. It allows the device to transfer the data directly to/from memory without any
interference of the CPU.
Using a DMA controller, the device requests the CPU to hold its data, address and control
bus, so the device is free to transfer data directly to/from the memory. The DMA data
transfer is initiated only after receiving HLDA signal from the CPU.
Initially, when any device has to send data between the device and the memory,
the device has to send DMA request (DRQ) to DMA controller.
The DMA controller sends Hold request (HRQ) to the CPU and waits for the CPU to
assert the HLDA.
Then the microprocessor tri-states all the data bus, address bus, and control bus.
The CPU leaves the control over bus and acknowledges the HOLD request through
HLDA signal.
Now the CPU is in HOLD state and the DMA controller has to manage the operations
over buses between the CPU, memory, and I/O devices.
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 can perform read transfer, write transfer and verify transfer
operations.
It generates MARK signal to the peripheral device that 128 bytes have been
transferred.
71
Microprocessors
8257 Architecture
The following image shows the architecture of 8257:
72
Microprocessors
The following image shows the pin diagram of a 8257 DMA controller:
DRQ0DRQ3
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.
DACKoDACK3
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.
DoD7
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
73
Microprocessors
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-A3
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-A7
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
74
Microprocessors
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.
75
Microprocessors
Microcontrollers
76
18. Microcontrollers Overview Microprocessors
The general microcontroller consists of the processor, the memory (RAM, ROM, EPROM),
Serial ports, peripherals (timers, counters), etc.
Microcontroller Microprocessor
Its designing and hardware cost is low. Its designing and hardware cost is high.
It is built with CMOS technology, which Its power consumption is high because it has
requires less power to operate. to control the entire system.
Types of Microcontrollers
Microcontrollers are divided into various categories based on memory, architecture, bits
and instruction sets. Following is the list of their types:
Bit
Based on bit configuration, the microcontroller is further divided into three categories.
77
Microprocessors
Memory
Based on the memory configuration, the microcontroller is further divided into two
categories.
Instruction Set
Based on the instruction set configuration, the microcontroller is further divided into two
categories.
CISC: CISC stands for complex instruction set computer. It allows the user to insert
a single instruction as an alternative to many simple instructions.
RISC: RISC stands for Reduced Instruction Set Computers. It reduces the
operational time by shortening the clock cycle per instruction.
Applications of Microcontrollers
Microcontrollers are widely used in various different devices such as:
78
19. 8051 Architecture Microprocessors
In the following diagram, the system bus connects all the support devices to the CPU. The
system bus consists of an 8-bit data bus, a 16-bit address bus and bus control signals. All
other devices like program memory, ports, data memory, serial interface, interrupt
control, timers, and the CPU are all interfaced together through the system bus.
External
Interrupts
On-Chip
INT0 INT1
ROM
(for
Counter Inputs
Interrupt On-Chip ETC
Program
Control RAM T1
code) Timer 0
Timer 1
T0
CPU
30PF 30PF
TXD RXD
Address/Data
4 to 30 MHz
79
20. 8051 Pin Description Microprocessors
Pins 1 to 8: These pins are known as Port 1. This port doesnt serve any other
functions. It is internally pulled up, bi-directional I/O port.
Pin 9: It is a RESET pin, which is used to reset the microcontroller to its initial
values.
Pins 10 to 17: These pins are known as Port 3. This port serves some functions
like interrupts, timer input, control signals, serial communication signals RxD and
TxD, etc.
Pins 18 & 19: These pins are used for interfacing an external crystal to get the
system clock.
Pin 20: This pin provides the power supply to the circuit.
80
Microprocessors
Pins 21 to 28: These pins are known as Port 2. It serves as I/O port. Higher order
address bus signals are also multiplexed using this port.
Pin 29: This is PSEN pin which stands for Program Store Enable. It is used to read
a signal from the external program memory.
Pin 30: This is EA pin which stands for External Access input. It is used to
enable/disable the external memory interfacing.
Pin 31: This is ALE pin which stands for Address Latch Enable. It is used to
demultiplex the address-data signal of port.
Pins 32 to 39: These pins are known as Port 0. It serves as I/O port. Lower order
address and data bus signals are multiplexed using this port.
Pin 40: This pin is used to provide power supply to the circuit.
81
21. 8051 Input Output Ports Microprocessors
8051 microcontrollers have 4 I/O ports each of 8-bit, which can be configured as input or
output. Hence, total 32 input/output pins allow the microcontroller to be connected with
the peripheral devices.
Pin configuration, i.e. the pin can be configured as 1 for input and 0 for output
as per the logic state.
o Input/Output (I/O) pin: All the circuits within the microcontroller must be
connected to one of its pins except P0 port because it does not have pull-up
resistors built-in.
o Input pin: Logic 1 is applied to a bit of the P register. The output FE transistor
is turned off and the other pin remains connected to the power supply voltage
over a pull-up resistor of high resistance.
o When the external memory is used then the lower address byte (addresses A0-
A7) is applied on it, else all bits of this port are configured as input/output.
o When P0 port is configured as an output then other ports consisting of pins with
built-in pull-up resistor connected by its end to 5V power supply, the pins of
this port have this resistor left out.
Input Configuration
If any pin of this port is configured as an input, then it acts as if it floats, i.e. the input
has unlimited input resistance and in-determined potential.
Output Configuration
When the pin is configured as an output, then it acts as an open drain. By applying logic
0 to a port bit, the appropriate pin will be connected to ground (0V), and applying logic 1,
the external output will keep on floating.
In order to apply logic 1 (5V) on this output pin, it is necessary to build an external pull-
up resistor.
Port 1
P1 is a true I/O port as it doesnt have any alternative functions as in P0, but this port can
be configured as general I/O only. It has a built-in pull-up resistor and is completely
compatible with TTL circuits.
Port 2
P2 is similar to P0 when the external memory is used. Pins of this port occupy addresses
intended for the external memory chip. This port can be used for higher address byte with
82
Microprocessors
addresses A8-A15. When no memory is added then this port can be used as a general
input/output port similar to Port 1.
Port 3
In this port, functions are similar to other ports except that the logic 1 must be applied to
appropriate bit of the P3 register.
When these pins are configured as inputs (i.e. logic 1), then built-in pull-up
resistors provide very weak current, but can activate up to 4 TTL inputs of LS series.
If all 8 bits of a port are active, then the total current must be limited to 15mA
(port P0: 26mA).
If all ports (32 bits) are active, then the total maximum current must be limited to
71mA.
83
22. 8051 Interrupts Microprocessors
Interrupts are the events that temporarily suspend the main program, pass the control to
the external sources and execute their task. It then passes the control to the main program
where it had left off.
8051 has 5 interrupt signals, i.e. INT0, TFO, INTR1, TF1, RI/TI. Each interrupt can be
enabled or disabled by setting bits of the IE register and the whole interrupt system can
be disabled by clearing the EA bit of the same register.
We can change the priority levels of the interrupts by changing the corresponding bit in
the Interrupt Priority (IP) register as shown in the following figure.
A low priority interrupt can only be interrupted by the high priority interrupt, but
not interrupted by another low priority interrupt.
If two interrupts of different priority levels are received simultaneously, the request
of higher priority level is served.
If the requests of the same priority levels are received simultaneously, then the
internal polling sequence determines which request is to be serviced.
TCON Register
TCON register specifies the type of external interrupt to the microcontroller.
85
Microprocessors
Peripheral Devices
86
23. Intel 8255A Programmable Peripheral Interface
Microprocessors
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 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.
87
Microprocessors
Features of 8255A
The prominent features of 8255A are as follows:
8255 Architecture
The following figure shows the architecture of 8255A:
88
24. Intel 8255A Pin Description Microprocessors
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.
89
Microprocessors
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 & 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.
Result
A1 A0 RD WR CS
Input operation
0 0 0 1 0 PORT A Data Bus
0 1 0 1 0 PORT B Data Bus
1 0 0 1 0 PORT C Data Bus
Output Operations
0 0 1 0 0
Data Bus PORT A
0 1 1 0 0 Data Bus PORT B
1 0 1 0 0 Data Bus PORT C
1 1 1 0 0 Data Bus Control
90
25. Intel 8253 Programmable Interval Timer
Microprocessors
The Intel 8253 and 8254 are Programmable Interval Timers (PTIs) designed for
microprocessors to perform timing and counting functions using three 16-bit registers.
Each counter has 2 input pins, i.e. Clock & Gate, and 1 pin for OUT output. To operate a
counter, a 16-bit count is loaded in its register. On command, it begins to decrement the
count until it reaches 0, then it generates a pulse that can be used to interrupt the CPU.
8253 8254
Its operating frequency is 0 - 2.6 MHz Its operating frequency is 0 - 10 MHz
It uses N-MOS technology It uses H-MOS technology
Reads and writes of the same counter Reads and writes of the same counter can
cannot be interleaved. be interleaved.
Features of 8253 / 54
The most prominent features of 8253/54 are as follows:
These three counters can be programmed for either binary or BCD count.
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.
91
Microprocessors
8254 Architecture
The architecture of 8254 looks as follows:
92
Microprocessors
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.
Read/Write Logic
It includes 5 signals, i.e. RD, WR, CS, and the address lines A0 & A1. In the peripheral I/O
mode, the RD and WR signals are connected to IOR and IOW, respectively. In the memory-
mapped 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
1 1 Control word Register
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
1 1 1 0 0 Write Control Word
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 Disabled
93
Microprocessors
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.
94
26. Intel 8253/54 Operational ModesMicroprocessors
8253/54 can be operated in 6 different modes. In this chapter, we will discuss these
operational modes.
Initially the output is low after the mode is set. The output remains LOW after the
count value is loaded into the counter.
The process of decrementing the counter continues till the terminal count is
reached, i.e., the count become zero and the output goes HIGH and will remain
high until it reloads a new count.
The GATE signal is high for normal counting. When GATE goes low, counting is
terminated and the current count is latched till the GATE goes high again.
The output remains high until the count is loaded and a trigger is applied.
Whenever the count becomes zero, another low pulse is generated at the output
and the counter will be reloaded.
On the terminal count, the output goes low for one clock cycle then goes HIGH.
This low pulse can be used as a strobe.
95
Microprocessors
This mode is similar to mode 4 except that the counting is initiated by a signal at
the gate input, which means it is hardware triggered instead of software triggered.
When the terminal count is reached, the output goes low for one clock cycle.
96