Microprocessor Chapter 2
Microprocessor Chapter 2
10
INSTRUCTION CYCLE computer to perform:aspecified
3.2 a command given to the programmer
An instruction is a
a particular task writes
given data. To
perform data are stored a
a program. Program and in the mernoryher
instructions, called memory ata time and executes it.
one instruction from the to the final result.
fetches
a program
one by one to produce
of
instructions out to fetch an instruction
necessary steps that a CPU carries ann instruction
The
memory, and to execute it, constitute cycle.
data from the execute cycle, In fetch cycle a CPU Aninsi
cycle and fetches
cycle consists of fetch
a
memory. The necessary op
code of an instruction) from the steps
machine memory, constitute a fetchcycle. wi
an opcode from the
carried out to fetch
out to get data, if any, from the memory and
The
ne
steps which are carried to
an instruction, constitute an execute perton
specific operation specified in a fixed slot of time while
cycle.
an opcode (FC) is the ime The
required to fetch which depends on requi
execute an instruction (EC) is variable thetype ofb instrucian
executed. The total time required to execute an instruction is given
IC = FC+ EC
buffer in Intel 8085) and then to instruction register, IR. From the instruction re
goes to the decoder circuitry which decodes
the instruction. The decoder cia
within the microprocessor. After the instruction is decoded, execution begis
operand is in the general purpose registers, execution is immediately pertoT
time taken in decoding and execution is one
or
clock cycle. If an instruction conu
operand address which are still memory,the CPU has to perform
so
CLOCK
EC
<br>
MICROPROCESSOR ARCHTECTUNE
211
roeived from the memory are data or operand
instructions write operation is performed,In address instead are
of an opcode. In sOme
write cvele data sent
the memory an output
[Link], we see that in sone cases an from the CPU to
or
TIME
CPU
INSTRUCTION
DECODER
PROGRAM MEMORY
MAR ADDRESs
CONTROL COUNTER
BUS
TEMPORARY
REGISTER ACCUMULATOR
DR
GENERAL PURPOSE
REGISTERS TO
DATA BUS
ALU MEMORY
<br>
SIGNAL Tg T
CLK
IOM
S, So
Ag-A15 TX PCH
OUT IN
ALE
RD
and
read cyce.
M
CLK
1O/M
So
S, So
Ag-A15
PC (MSBs) OF ADDRESS (PC+1)H
OUT IN OUT IN
RD
MICROPROCESSOR ARCHITECTURE
3.15
SIGNAL T T2 Ta
CLK
SIGNAL
T2 T3
10M CLK
So IO/M
A-A15 PCH So
OUT IN
AgrAysX
AD,-AD, PCL DATA
AD,AD;XAoa Do-D,
ALE ALE
RD WR
Fig. 3.11 Timing Diagram for Memory Read Fig. 3.12 Timing Diagram for Memory Write
Operation Operation
respectively for read operation, see Table 3.1. On the address lines Ag -A15, the 8
MSBs of the memory address of the data (05) are sent. During T, 8 LSBs of the memory
address of the data are sent on ADo -AD¬. During T,8 LSBs of the address is latched
RD goes low in T, to enable the
and ADo -AD, are made free for data transmission.
memory for read operation. Now, data is placed on data bus. During T, the data enters
into the CPU. In T3, RDgoes high and disables the
memory. For MVI A, 05 instruction
the data enters into the accumulator. The timing diagram for
an opcode fetch cycle and
a memory read cycle are same except the status signals S, and So. MR cycle consists of
only three clock cycles.
Now, consider a three byte long instruction, for example; LXI H, 2500H. This
memory
instruction requires three maehine cycles, one fetch cycle and two consecutive
to
read cycles. The 1st machine cycle is to fetch the opcode, the 2nd machine cycle read
8
LSBs of the 16-bit data (2500), and the 3rd machine cycle to read 8 MSBs of the 16-bit
data (2500). The instruction LDA2400H requires four machine cycles. The 1st machine
cycle is to fetch the operation code, the 2nd machine cycle for reading the 8LSBs of the
memory address (2400H), the third machine cycle for reading 8 MSBs of the memory
address. In the fourth machine cycle the microprocessor sends the memory address
2400H toget its content into the accumulator.
3.3.3 VO Read
In an I/O read cycle the microprocessor reads the data available at an input port or
input device. The data is placed in the accumulator. An I/0 read cycle is similar to
memory read cycle. The only differernce between a memory ready cycie and I/O read
cycle is that signal IO/M goes high in case of I/Oread. It indicates that the address
on
the A-bus is for an input device. In timing diagram all other signals will remain same as
3.16
shown in Fig. 3.11. n case of I/O device orlI/O portonthe address is onlw 8s.
therefore, the address of I/O device is duplicated both and ADbuses,)
A A
The IN instruction is used for I/O read. It is two byte long. It requires
machine cycles for execution. The first machine cycle is opcode fetch cycle, s
device (or the
machine cycle is a memory read cycle to read the input input port)
and the third machine cycle is I/Oread cycle read the data fromthe device
to
orpn
3.3.4 Memory Write
In memory write cycle the CPU sends data from the accumulator: or any other
a
tep
to the memory. The timing diagram fora memory write cycle is showniin Fig-312
status signals S and S are 1 and respectively for write operation. WR goesloW
O
or I/O port. The address of an I/O port or device is duplicated on both A and ADi
The OUT instruction is used for I/Owrite. It is a two byte long instruction. It
reçu
three machine cycles. The first machine cycle is for opcode fetch operation, the setn
machine cycle is a memory read cycle for reading the I/0 device address fromá
memory and the third machine cycle is an I/O write cycle for sending data to thel,
device.
PROBLEMS
1. What are the various registers of 8085? Discuss their function.
2. Discuss the function of ALUof 8085.
3. What are various status flags provided in 8085? Discuss their roles.
4. Discuss the function of the following signals of 8085:
IO/M, INTR, INTA, HOLD, HLDA and READY.
5. Discuss the function of the following signals of 8085:
RD, WR, ALE,
S and S1.
6. Discuss instruction cycle, machine cycle and state.
7. Discuss fetch operation and execute operation.
8. Draw and explain the timing diagram for fetch operation.
9. Draw and explain the timing diagram for memory read operation.
10. Draw and explain the timing diagram of memory write operation.
data.
11. Draw and explain the
timing diagram for the instruction MVIr,
12. Draw and explain the timing diagram for
13. Draw and explain the timing diagram for
I/0 read operation.
14. How many machine cycles are
I/0 write operation.
instructions of
Intels
HAPIER 7
PERIPHERAL DEVICES
AND INTERFACING
INTRODUCTION
7.1
microprocessor combined with memory and devices, forms
a
A
7.2 FUNDAMENTALS OF
MICROPROCESSORS ANDI MICROCOTHOLE
MEMORY VO DEVICE
ADDRESS BUS
DATA BUS
CONTROL BUS
MEMORY
PROM
CHIP SELECT
Y
SIGNALs PROM
RAM
Y
DECODER-1 RAM
RAM
RAM
IOM ENABLE UNUSED
RESERVED
FOR FUTURE
Yo
ENABLE NPUT DEVICE
Y.
INPUT DEVICE
OUTPUT DEVICE
OUTPUT DEVICE
DECODER-2 Y
UNUSED
VO DEVICE RESERVED
SELECT FOR FUTURE
SIGNALS
output lines become high. Thus, 74LS138 acts as decoder only when G1 is high, and
G2A and G2B are low.
The memory locations for EPROM1 will lie in the range 0000 to 1FFF. These
are the
memory locations for ZONE 0 for the memory chip which is connected to the output
7 E000 to
line Y, of the decoder. Similarly, for ZONE is 2000 to 3FFF and for ZONE is
1
H H H H H H
X X X X X I I I
L H H H H I I
H I
I
H I
H H I H IH H H
H H I H L H H IH H IH
I
H L H H
H IH I I I I
H
L I
I
L H I
H L II I I
H
II H H H
H L
I
H IH I I
H H I
H
H L H I
H
IIH H H H
H H H H I
H H I
I
XDenotes
irrelevant
<br>
FUNDAMENTALS OF MICROPROCESSORS
SAND MICROCONTROAL
7.4
Ays
EPROM 1
Y614 EPROM 2
A2
13
Ag RAM 1
12
RAM 2
11
6 RAM 3
5V
74LS138
10
5 RAM 4
IOM
G24 RAM 5
RAM 6
16 G
Vcc
GND
Yo EPROM 1
ZONE O 0000 to 1FFF
EPROM2 ZONE 1
2000 to 3FFF
Y2 RAM 1 ZONE 2 4000 to 5FFF
RAM 2 ZONE 3 6000 to 7FFF
RAM 3 ZONE 4 8000 to 9FFF
RAM 4 ZONE 5 A000 to BFFF
Y6 RAM 5 ZONE 6 CO00 to DFFF
RAM 6 7 E000 to FFFF
Y7 ZONE
The entire memory address (64K for 8085) has been divided into 8 zones. Adtre
of the 74LSI
lines A15, A14 and Aj3 have been applied to the select lines A. Band C EPROM or a
The logic applied to these lines selects a particular memory device, an
..
RAM. Other address lines A, Aj,A, and Aj go directly to memory hi
decide the address of the memory location within a selected memory chipG2Bgoes
connected to G2B. When IO/M goes low for memory read/write operation,
low. G1 is connected to + 5 Vac. Supply and G2A is grounded.
7.3.2 VO Interfacing addes
the
Figure 74 shows the interface I/O devices through decoder 7474LS138. As for I/O
of
of an
used
I/O device is of 8 bits, only Ag -A1s lines of address bus areselectlines
addressing. The address lines Ag, Ag and A10 have been applied to aa
NAN
and C of through
the 74LS138. The address lines A1 -A1s are appliedlto G2B high. G24
gate. G2B becomes low only when all address lines A writ
-Ajs are read/
grounded. IO/M is connected to G1. When IO/M goes high tor I/0Connectet
operation, Gl goes high. Table 7.3 shows the addresses of devices
74LS138.
I/0
Ae
- INPUT DEVICE 1
INPUT DEVICE 2
INPUT DEVICE 3
As
A4 12
5
lyw OUTPUT DEVICE 1
Ays
G28
Y OUTPUT DEVICE 2
A2
74LS138 10
At Ys
b OUTPUT DEVICE 3
G2A
UNUSED
FOR FUTURE
7 EXPANTION
IO G,
k
16 Vcc
8
GND