EE3404 - Microprocessor and Microcontroller
EE3404 - Microprocessor and Microcontroller
1
1. Timing and Control unit
This unit synchronizes all the microprocessor operations with the clock and generates control signals
necessary for communicate between microprocessor and peripherals.
The RD.WR signals are sync pulses indicating the availability of data on data bus.
The ALU performs the actual numerical and logic operation such as ‘add’, ‘subtract’, ‘AND’, ‘OR’, etc.
Uses data from memory and from Accumulator to perform arithmetic.
Always stores result of operation in Accumulator.
3. Register Array
The 8085 includes six registers, one accumulator and one flag register. In addition, it has two 16-
bit registers: stack pointer and program counter.
The 8085 has six general-purpose registers to store 8-bit data; these are identified as B, C, D, E, H, and
L
They can be combined as register pairs - BC, DE, and HL - to perform some 16-bit operations
The programmer can use these registers to store or copy data into the registers by using data copy
instructions
The HL register pair is also used to address memory locations
The accumulator is an 8-bit register that is a part of ALU. This register is used to store 8-bit data and to
perform arithmetic and logical operations. The result of an operation is stored in the accumulator. The
accumulator is also identified as register A.
Program Counter - Deals with sequencing the execution of instructions. Acts as a memory pointer.
Stack Pointer – Points to a memory location in R/W memory, called the stack.
Instruction register
It is an 8-bit register that temporarily stores the current instruction of a program. Latest
instruction sent here from memory prior to execution.
2
Decoder then takes instruction and decodes or interprets the instruction. Decoded instruction
then passed to next stage.
Flag register
The ALU includes five flip-flops, which are set or reset after an operation according to data
conditions of the result in the accumulator and other registers.
They are called Zero (Z), Carry (CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags.
CY-Carry flag. If the sum in the accumulator is larger than eight bits, the flip-flop uses to indicate a
carry called the Carry flag (CY) is set to one.
Z-Zero flag .When an arithmetic operation results in zero, the flip-flop called the Zero (Z) flag is set
to one.
AC-auxillary carry flag. In arithmetic operations, when a carry is generated by Digit D4 and passed
to D5 ,the AC Flag is set.
P-Parity flag- This flag is set when the result of the instruction has odd number of 1’s.
S-Sign flag-In arithmetic operation with signed number, the D7 bit is reserved for indicating the
sign.
The combination of the flag register and the accumulator is called Program Status Word (PSW) and
PSW is the 16-bit unit for stack operation.
5. System bus
Data Bus:
Data bus carries data in binary form between microprocessor and other external units such as
memory.
Data bus is bidirectional in nature.
The data bus width of 8085 microprocessor is 8-bit.
Address Bus:
The address bus carries addresses and is one way bus from microprocessor to the memory or
other devices. 8085 microprocessor contain 16-bit address bus and are generally identified as
A0 - A15.
The higher order address lines (A8 – A15) are unidirectional and the lower order lines (A0 –
A7) are multiplexed (time-shared) with the eight data bits (D0 – D7) and hence, they are
bidirectional.
3
Control Bus: Control buses are various lines which have specific functions for coordinating and
controlling microprocessor operations. Ex.read/Write controlline
6. Interrupt control
Interrupt is a signal ,which suspends the routine what the MP is doing, brings the control to perform the
subroutines,completes it and returns to main routine.E.g. INTR,TRAP,RST 7.5,RST 6.5 ,RST 5.5
**********************************************************************
Draw and explain pin diagram and functional block diagram of 8085.(Dec 2014, April 2018)
Explain 8085 with signal diagram.
***********************************************************************
8085 Pin diagram
Figure shows 8085 pin configuration and functional 8085 Microprocessor Pin Diagram respectively.
The signals of 8085 can be classified into seven groups according to their functions.
4
a)Pin configuration b)Functional pin diagram
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.
5
Three status signals are IO/M, S0 & S1.
S1 & S0
S0 and S1 are called Status Pins. They tell the current operation which is in progress in 8085.
IO/M
This signal is used to differentiate between I/O and Memory operations, i.e.
Interrupt 1 1 1 INTA=0
Acknowledge
6
Power supply
There are 2 power supply signals VCC & VSS.
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.
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.
SID (Serial input data line) − The data on this line is loaded into accumulator whenever a RIM
instruction is executed.
7
Five Hardware Interrupts in 8085
TRAP is a non-maskable interrupt
RST 7.5 is an edge triggered interrupt.
RST 6.5 is a maskable and level triggered interrupt
RST 5.5 is a maskable and level triggered interrupt
INTR is a non-vectored interrupt
************************************************************************************************
Explain the memory organization of 8085
**************************************************************************************
3. Memory Organization (R/W Memory):
Memory is an essential component of a microcomputer system. It stores binary instructions and data for
the microprocessor. There are two types of memory: Read/Write Memory(R/WM) and Read-only Memory
(ROM). The 8085 has 16 address lines. That means it can address upto 2 16=64 Kbytes.
8
Fig: Interfacing 8085 with ROM
9
How the MPU writes into and Read from memory?
****************************************************************************
Explain I/O Interfacing in 8085 .
*****************************************************************************
4. 8085 Interfacing with I/O devices
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 .
Microprocessor needs to Identify I/O devices with binary number. I/O devices can be interfaced in three
steps.
1. Identify the memory location (with address).
2. Generate timing and control signal.
3. Data transfer takes place.
10
The techniques used for I/O interfacing are
1. Memory mapped I/O
2. I/O mapped I/O or Peripheral mapped I/O
1. Memory-Mapped I/O
In memory mapped I/O, each device has an address just like a memory location.
The memory map (64K) is shared between I/O device and system memory.
Instructions STA/.LDA and MOV are used for data transfer.
Device is identified by 16-bit address (Space ranges from 0000H –FFFFH).
For data transfer from input device to processor the following operations are performed
1. The MPU places an 8-bit device address on address bus then decoded.
2. The MPU sends a control signal (IOR or IOW) to enable the I/O device.
3. Data are placed on the data bus for transfer.
Data transfer from processor to output device the following operations are performed.
To send data to O/P device :-
1. The MPU places the device address (output port no.) on the address bus.
11
2. The MPU places data on data bus.
3. The MPU enables the output device using the control signal (IOW).
4. The O/P device latches and displays data (if O/P = LED). The other peripherals that are not enabled
remain in a high impedance state called (tri-state).
**************************************************************************************************
Write short notes on Data transfer concept
******************************************************************************************
4.2. Data Transfer Concepts
The 8085 microprocessor is a parallel device. That means it transfers eight bits of data simultaneously
over eight data lines (parallel I/O mode).
However in many situations, the parallel I/O mode is either impractical or impossible. For example,
parallel data communication over a long distance becomes very expensive.
Similarly, parallel data communication is not possible with devices such as CRT terminal or Cassette
tape etc
Data transfer between microprocessor to memory and microprocessor to I/O devices is explained in the following ways
The data transfer can be classified into
Parallel data transfer scheme is faster than serial I/O transfer. in parallel data transfer 8-bit data send all
together with 8 parallel wire. It is further divided into
12
Programmed I/O
Interrupt I/O
DMA
Programmed I/O :
Here the processor has to check whether the I/O device is ready or not through the Ready signal of the
I/O device.
If the ready signal is high then it will send the data to the I/O device.
Otherwise it will continuously check the Ready signal.
The processor is busy in checking the Ready signal.
The drawback is wastage of time.
Interrupt I/O:
In this method the I/O device will interrupt the Processor through the INTR signal to indicate to the
processor that it is ready to accept the next data.
Then the processor will send the INTA signal.
Then the processor stops its normal execution and start transferring the data to the I/O device.
DMA:
Using DMA I/O device can directly transfer the data to the Memory using the Address and Data buses
of Processor.
II. Serial data Transfer
Some of the external I/0 devices receive only the serial data. Normally serial communication is used
in the Multiprocessor environment.
In serial I/O mode transfer a single bit of data on a single line at a time. For serial I/O data
transmission mode, 8-bit parallel word is converted to a stream of eight serial bit using parallel-to-
serial converter.
Similarly, in serial reception of data, the microprocessor receives a stream of 8-bit one by one which
are then converted to 8- bit parallel word using serial-to-parallel converter.8051 has two pins for
serial communication.
SID- Serial Input data.
SOD-Serial Output data
************************************************************************************************
Explain the interrupt structure of 8085.(Dec 2013, April 2015,Dec 2015,June 2014,June 2016)
Explain the interrupts of 8085 with its types with interrupt service routine.(April 2018,Dec 2018)
******************************************************************************************
13
5. Interrupts in 8085
5.1. Interrupt
Definition:
1. Interrupt is the mechanism by which the processor is made to transfer control from its current program
execution to another program having higher priority. The interrupt signal may be given to the processor
by any external peripheral device
2. 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.
14
Maskable and Non-Maskable interrupt
Maskable interrupt − In this type of interrupt, we can disable the interrupt by writing some
instructions into the program. For example: RST7.5, RST6.5, RST5.5.
Non-Maskable interrupt − In this type of interrupt, we cannot disable the interrupt by writing some
instructions into the program. For example: TRAP.
The ‘EI’ instruction is a one byte instruction and is used to Enable the maskable interrupts.
The ‘DI’ instruction is a one byte instruction and is used to Disable the maskable interrupts
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.
Hardware interrupt − There are 5 interrupt pins in 8085 used as hardware interrupts, i.e. TRAP,
RST7.5, RST6.5, RST5.5, INTA.
Note − NTA is not an interrupt, it is used by the microprocessor for sending acknowledgement. TRAP has the
highest priority, then RST7.5 and so on.
Interrupt Priority
TRAP 1
RST 7.5 2
RST 6.5 3
RST 5.5 4
INTR 5
15
Figure:Interrupt service routine procedure
1. It allows the external devices to interrupt the normal program execution of the microprocessor.
2. When microprocessor receives interrupt signal, it temporarily stops current program and starts executing
new program indicated by the interrupt signal.
3. Interrupt signals are generated by external peripheral devices like keyboard, sensors, printers etc.
4. After execution of the new program, microprocessor returns back to the previous program.
16
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.
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.
• The Interrupt Enable flip flop is manipulated using the EI/DI instructions.
• The individual masks for RST 5.5, RST 6.5 and RST 7.5 are manipulated using the SIM instruction.
This instruction takes the bit pattern in the Accumulator and applies it to the interrupt mask enabling and
disabling the specific interrupts
SIM Instruction:
The SIM instruction is used to mask or unmask RST hardware interrupts. When executed, the SIM instruction
reads the content of accumulator and accordingly mask or unmask the interrupts. The format of control word to
be stored in the accumulator before executing SIM instruction is as shown in Fig.
17
RIM Instruction:
RIM instruction is used to read the status of the interrupt mask bits. When RIM instruction is executed, the
accumulator is loaded with the current status of the interrupt masks and the pending interrupts. The format and
the meaning of the data stored in the accumulator after execution of RIM instruction is shown in Fig
Ex: Write an assembly language program to enables all the interrupts in 8085 after reset.
EI : Enable interrupts
MVI A, 08H : Unmask the interrupts
SIM : Set the mask and unmask using SIM instruction
******************************************************************************************
18
Timing Diagram
1. Instruction cycle: this term is defined as the number of steps required by the CPU to complete the entire
process ie. Fetching and execution of one instruction. The fetch and execute cycles are carried out in
synchronization with the clock.
2. Machine cycle: It is the time required by the microprocessor to complete the operation of accessing the
memory devices or I/O devices. In machine cycle various operations like opcode fetch, memory read,
memory write, I/O read, I/O write are performed.
3. T-state: Each clock cycle is called as T-states.
19
Opcode fetch
The microprocessor requires instructions to perform any particular action.
In order to perform these actions microprocessor utilizes Opcode which is a part of an instruction
which provides detail (ie.which operation µp needs to perform) to microprocessor.
Memory Read
For example MVI A,32 (April 2018)
The total cycle consists of 7 T states and 2 machine cycles.opcode fetch and memory read.
20
At the end of opcode fetch the PC is incremented thus the address is 2001H and the instruction
decoder has 3EH.Now the operand is to be read from the memory to Register A.
The 2nd m/c cycle are similar to first 3 states of opcode exept the status signal(S0=0 and S1=1)
Memory Write
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
I/O read
The I/O Read cycle is executed by the processor to read a data byte from I/O port or from the
peripheral.
The processor takes 3T states to execute this machine cycle.
The IN instruction uses this machine cycle during the execution.
21
I/O write
Example OUT 01H stored at memory location 2050.The opcode of the instruction is D3
The processor takes, 10T states to complete the cycle.It requires 3 machine cycle opcode fetch,memory
read and memory write.
22
23