Professional Documents
Culture Documents
MODULE III
MICROPROCESSOR SYSTEMS
STUDY NOTES
Classification of microprocessors
Microprocessors are specified by its ‘word size’, (the size of its data bus). E.g. 4-bit, 8-bit etc.
4-bit Microprocessors - 1st generation
Intel 4004 Fairchild PPS-25
Intel 4040 Rockwell PPS-4
8-bit Microprocessors - 2nd generation
Intel 8008 Intel 8085 Rockwell PPS-8
Intel 8080 Motorola M6800 Zilog Z-80
Characteristics of 8-bit microprocessors
Large chip size. Ability to address more I/O ports.
40-pins More powerful Instruction set
More number of on-chip decoded Faster operation
timing signals. Better interrupt handling capabilities.
Ability to address larger memory
space.
16-bit Microprocessors - 3rd generation
Intel 8086 Intel 8088 Intel 80186 Intel 80286
Microprocessor Architecture
A microprocessor consists of the following basic units/functional blocks:
i. Arithmetic Logic Unit (ALU) subsystem
ii. Memory subsystem
iii. Input/output subsystem
iv. Control unit
Schematic arrangement of a microprocessor
Control unit
ALU
Data bus
LM Memory Address CP
Register (MAR) 88 88 LP
CLK
Program Counter CLK
(PC) EP
88
CLR
88
Program counter: It is a 16-bit reg. It stores the address of the next instruction to be executed.
Index Register: It is used to point at blocks of data in memory
Input / Output sub-system
Input devices includes:
8 A/D
8
Bus
L1 CLK
8 (8) 8
CLK Input Register Output Register
LO
E1
Control Unit:
It directs various sub-systems/units to act in a desired way. It coordinates and synchronizes their
functioning. It consists of the:
Instruction register Timing and control unit
Instruction decoder
Block diagram of the control unit
LC Instruction register
CLR A/D
8
CLK
Bus
EC
8 (8)
Instruction decoder
Clock pulses
© N. Koech 2021signals
Control Microprocessor Systems 1st Ed.
Instruction register: it stores the code of the instruction currently being executed
Instruction decoder: it decodes the instructions received from the instruction register and
directs the control unit to produce necessary control signals.
Control and timing unit: it produces the control signals required for the operation of various
sub-systems.
Other registers
Stack pointer
Stack: it is a set of memory locations reserved by a programmer for saving the address in the
program counter.
Stack pointer: it stores the address of a memory location belonging to the most recent entry in
the stack. It is used to save data of another general purpose register during execution of a sub-
routine or when an interrupt is serviced.
General purpose registers (B, C, D, E, H and L)
They are used to store data and address information. This enhance the processing speed of a
microprocessor by avoiding a large number of external memory read/write operations. Each
register can hold 8-bit data. They can also work as register pairs to hold 16 bit data. Their pairing
combination is: B-C, D-E and H-L
Temporary registers (W and Z)
They are used when data have to be stored during the execution of a machine instruction.
Accumulator (Register A)
It stores the result of an operation. During arithmetic and logic operation, one of the operands is
always taken into the accumulator.
Flag Register/Status register
It stores the status outputs of the result of an operation and gives additional information about the
result of an ALU operation. Flag register is an 8-bit register. Intel 8085 has five flags as shown:
D7 D6 D5 D4 D3 D2 D1 D0
S Z XX AC XX P XX CY
Buses – it is a group of connecting wires or lines over which electrical signals are transmitted.
The three buses are:
i. Address bus
ii. Data bus
iii. Control bus
Bus structure/ organization
Address bus
Microprocessor
Data bus
Control bus
Address bus:
It is used to carry and address signals of memory location or I/O devices.
It is unidirectional.
Data bus
It is used for sending and receiving data by a microprocessor to & from memory and I/O devices.
It is bidirectional.
Control bus
It is used for transmitting and receiving control signals between the microprocessor and other
devices. E.g. memory read, I/O read, memory write and I/O write.
o A8 - A15 (Output): These are address bus and are used for the most significant bits of
the memory address or 8-bits of I/O address.
o AD0 - AD7 (Input/output): These are time multiplexed address/data bus i.e. they serve
dual purpose. They are used for the least significant 8 bits of the memory address or I/O
address during the first cycle. Again they are used for data during 2nd and 3rd clock
cycles.
S1 S0 Operations
0 0 HALT
0 1 WRITE
1 0 READ
1 1 FETCH
o HOLD (INPUT): HOLD indicates that another device is requesting for the use of the
address and data bus.
o HLDA (OUTPUT): HLDA is a signal for HOLD acknowledgement which indicates
that the HOLD request has been received. After the removal of this request the HLDA
goes low.
TRAP 0024
RST 7.5, RST 6.5 and RST 5.5 are the restart interrupts which cause an internal restart to be
automatically inserted.
The TRAP has the highest priority among interrupts. The order of priority of interrupts is as
follows:
Reset Signals
o RESET IN (Input): It resets the program counter (PC) to 0. It also resets interrupt enable
and HLDA flip-flops. The CPU is held in reset condition till RESET is not applied.
o RESET OUT (Output): RESET OUT indicates that the CPU is being reset.
Clock Signals
o SID (Input): SID is data line for serial input. The data on this line is loaded into the
seventh bit of the accumulator when RIM instruction is executed.
o SOD (Output): SOD is a data line for serial output. The seventh bit of the accumulator
is output on SOD line when SIM instruction is executed.
Power Supply
Instructions
Data
Opcode: The 1st part of an instruction which specifies the task to be performed by the computer.
Operand. The 2nd part of the instruction is the data to be operated on, and it is called The
Operand (or data) given in the instruction may be in various forms such as 8-bit or 16-bit data, 8-
bit or 16-bit address, internal registers or a register or memory location.
A digital computer understands instruction written in binary codes (machine codes). The binary
codes of all instructions are not of the same length.
According to the word size, the Intel 8085 instructions are classified into the following three
types:
All the above two examples are only one byte long. All one-byte instructions contain information
regarding operands in the opcode itself.
2. Two-byte instruction: In a two byte instruction the first byte of the instruction is its opcode
and the second byte is either data or address.
The first byte 06 is the opcode for MVI B and second byte 05 is the data which is to be moved to
register B.
3. Three-byte instruction: The first byte of the instruction is its opcode and the second and third
bytes are either 16-bit data or 16-bit address.
Example:
The first byte 21 is the opcode for the instruction LXI H. The second 00 is 8 LSBs of the data
(2400H), which is loaded into register L. The third byte 24 is 8 MSBs of the data (2400H), which
is loaded into register H.
Instruction Cycle
The time required to fetch an instruction and necessary data from memory and to execute it, is
called an instruction cycle. Or the total time required to execute an instruction is given by:
i. Fetch Cycle
Microprocessor places the contents of the program counter on the address bus and gets
instruction code, opcode from the addressed memory location. The microprocessor then saves
the opcode in the instruction register. The whole operation of fetching an opcode takes three
clock cycles. A slow memory may take more time.
The opcode fetched from the memory goes to the data register, DR and then to instruction
register, IR. The opcode in the instruction register is decoded with the help of the instruction
decoder to generate appropriate control signals to execute the instruction
In some situations, an execute cycle may involve one or more read or write cycles or both.
Read Cycle: If an instruction contains data or operand address which are in the memory, the
CPU has to perform some read operations to get the desired data. In case of a read cycle the
instruction received from the memory are data or operand address instead of an opcode.
Write Cycle: In write cycle data are sent from the CPU to the memory or an output device.
Start
Stop
Machine Cycle: It is the time required to access the memory or an I/O device. It is measured in
T-states (a clock period). The 8085 µP has seven machine cycles:
T-state: is one sub-division of an operation performed in one clock cycle. In short, one clock cycle of the
system clock is referred to as a state.
Timing Diagrams
The necessary steps carried out in a machine cycle can be represented graphically using a timing diagram.
ALE: ALE indicates the availability of a valid address on the multiplexed address/data lines. When it is high or
1, then it acts as an address bus and when low or 0, then it acts as a data bus.
RD (low active): If it is high or 1, then no data is read by the microprocessor. If signal is low or 0, then data is
read by the microprocessor.
WR (low active): If it is high or 1, then no data is written by the microprocessor. If signal is low or 0, then data
is written by the microprocessor.
IO/M (low active): A high or 1 on this signal indicates I/O operation while a low or 0 indicates memory
operation.
The below table, shows the status of different control signal for different operation:
Instruction format:
An instruction in assembly language program includes the following four fields:
i. Label field
© N. Koech 2021 Microprocessor Systems 1st Ed.
ii. Mnemonic field/opcode field
iii. Operand field
iv. Comment field.
Labels
It contains a sequence of letters and digits e.g. START, HERE etc.
It is used to identify the statement before which it occurs.
A label is separated from the rest of the statement by a colon.
Mnemonic/opcode
It is a sequence of characters used to represent an operation in a microprocessor. E.g. ADD, MOV, LXI etc.
Operands
It is a binary number on which an operation is to be carried out as per the instructions. It may be data or an
address.
e.g. MOV A, C
Opcode Operand
Comments
It gives a narrative description of the task which an instruction is supposed to take. This helps in understanding
the program.
A semicolon is used to separate a comment from the rest of the instructions.
An assembler ignores comment field during translation. It is only useful to the programmer and not the
microprocessor.
Assembler Delimiters
They are used to separate the four fields in an instruction. Typical delimiters are:
Spaces: used between fields
Commas: used between addresses in an operand field
Semicolon: used before a comment
Colon: used for a label.
LXI rp, data 16 Load Register pair 10 None Immediat 3 LXI H, 2500H
[rp] ←data 16 immediate data e
bits, [rh] ←8
MSBs, [rl] ←8
LSBs of data
Programming examples
1. Write an assembly language program to store the number D5H in register B.
2. Write an assembly language program to load the accumulator with data F2H, transfer this data to
register C.
3. Write an assembly language program to load the accumulator with contents of memory location
F230H, transfer these contents to register B.
MOV E, C MOV M, A
Arithmetic Group
The instructions of this group perform arithmetic operations such as addition, subtraction, increment or
decrement of the content of a register or a memory.
Notes
DAA – the contents of the accumulator is adjusted to change 8-bit binary number into two 4-bit BCD number.
DAD – the contents of the register pair is added to that of the H-L pair. The result I stored in H-L pair.
Programming examples
1. Write an assembly language program to add two numbers: 25H and 52H and store the result in
the memory location 2050H.
3. Write an assembly language program to multiply a number in memory location 2000H by 4 and
store the result in location 2008H.
ADD A MOV A, M
ADD A ADD A
4. Write an assembly language program to perform the following sequentially: Sum the numbers 48
and 17; multiply the result by 2; subtract 22 from the result; store the answer in memory location
2016H. (6mks)
ADD A ADD A
HLT HLT
MVI A, 3BH
ADD A
ADD A
ADI 0DH
HLT
MVI A, 12D
XRA
ADD A
MVI A, 18D
ADD A
RAR
HLT
HLT
Soln.
MVI A, X ADD A MVI A, Q
MOV B, A ADD A RRC
ADD A ADD D RRC
MOV C, A ADD C HLT
ADD A ADD B
MOV D, A HLT
Soln.
MVI A, 19H
LXI H, 3948H
MVI A, 6DH
ADD A
LXI B, 4ACEH
RAR
ADD A
DAD B
ORA A
ADD A
HLT
RAR
ADD A
HLT
HLT
9. Starting at address 3000H, write an assembly language program that will add two decimal
numbers 36748 located at memory address starting 3500H and 38117 located at memory address
starting 3502H. The result is stored in memory starting at 3504H. (8mks)
Soln.
Converting: 3674810 = 8F8CH
ORG 3000H OR 3811710 = 94E5H
XRA A
LDA 3500H
ORG 3000H
LXI H 3502H
XRA A
ADD M
MVI A, 8CH
STA 3504H
ADI E5H
LDA 3501H
STA 3504H
INX H
MVI A, 8FH
ADC M
ACI 94H
STA 3505H
STA 3505H
HLT
HLT
Soln. STC
CMC
HLT
11. Write an assembly language program to find the 2’s complement of data 16H
CMA CMA
HLT HLT
12. Write an assembly language program to carry out the arithmetic below using 2’s complement
method. 42H – 18H
MVI A, 18H
Soln. MVI A, 18H OR
CMA
CMA INR A
ADI 01H MVI B, 42H
ADI 42H ADD B
HLT HLT
13. Write an assembly language program to perform: 101001012 AND 23H
HLT ANA B
HLT
They alter the normal sequential program flow. Conditional flags are not affected by this group. They are
classified as:
Conditional transfer: examine the condition of one of the processor flags to determine if the specified branch
is to be executed.
Unconditional Jump
Conditional Jump
Jump addr Conditional jump: jump to the 10, if true and 3, if true and
(label) instruction specified by the address if 7, if not true 2, if not true
[PC] ← Label the specified condition is fulfilled
JZ addr (label) [PC] ← Jump, if the Jump if 7/10 None Immediate 2/3
address (label) result is zero Z=1
JNZ addr (label) Jump if the Jump if 7/10 None Immediate 2/3
[PC] ← address (label) result is not zero Z=0
JNC addr (label) Jump if there Jump if 7/10 None Immediate 2/3
[PC] ← address (label) is no carry CS =0
JPE addr (label) Jump if even The parity 7/10 None Immediate 2/3
[PC] ← address (label) parity status P =1
JPO addr (label) Jump if odd The parity 7/10 None Immediate 2/3
[PC] ← address (label) parity status P =0
Unconditional CALL
Conditional CALL
CALL addr (label) Unconditional CALL: Call 18, if true and 5, if true and
[SP]-1] ← [PCH] , [[SP-2] the subroutine identified by 9, if not true 2, if not true
CNZ addr Call Subroutine if Zero status 9/18 None Immediate 2/5
(label) the result is not Z=0 /register
zero
CPO addr Call subroutine if Parity Status 9/18 None Immediate 2/5
(label) odd parity P= 0 /register
Conditional Return
RNZ Return from subroutine Zero status 6/12 None Register 1/3
if result is not zero. Z= 0 indirect
RPE Return from subroutine Parity Status 6/12 None Register 1/3
if even parity. P= 1 indirect
RPO Return from subroutine Parity Status 6/12 None Register 1/3
if odd parity. P= 1 indirect
Restart
PCHL
Programming examples
1. Write an assembly language program to decrement data 05H stored in register B to zero.
MVI B, 05H
LOOP: DCR B
JNZ LOOP
HLT
Soln. XRA A
MVI B, 05H
LOOP: ADD B
DCR B
JNZ LOOP
HLT
MVI A, 32H
MVI B, 20H
MVI C, 42H
ADD B
ADD C
HLT
Soln.
Address Mnemonic Machine code
2001H MVI A, 32H 3E
2002H 32
2003H MVI B,20H 06
2004H 20
2005H MVI C, 42H 0E
2006H 42
2007H ADD B 80
2008H ADD C 81
2009H HLT 76
Example 2: The table below shows an 8085 hexadecimal machine code program. Using the 8085 instruction
set, convert the program into 8085 mnemonic program. (6mks)
Address Machine code Soln. LXI H, 3000H
2000H 21
2001H 00 LXI B, 4000H
2002H 30
DAD B
2003H 01
2004H 00 HLT
2005H 40
2006H 09
2007H 76
LXI H, 0870H
MOV A, L
MOV B, H
ADD B
ADD A
HLT
Soln.
Address Mnemonic Machine code
0000H MVI A,C8H 3E
0001H C8
0002H LXI B, 5640H 01
0003H 40
0004H 56
0005H ANA C A1
0006H ORA B B0
0007H RLC 07
0008H LXI H, 2000H 21
0009H 00
000AH 20
000BH SHLD 3000H 22
000CH 00
000DH 30
000EH HLT 76
Example 4: Given the program listing 1 below and Intel 8085 instruction set, hand-code it using hexadecimal.
Listing 1 ORG 0000H (8mks)
MVI A, C8H
LXI B, 5640H
ANA C
ORA B
RLC
LXI H, 2000H
SHLD 3000H
HLT
© N. Koech 2021 Microprocessor Systems 1st Ed.
Soln. Register contents
Address Mnemonic Machine code A H L B
0000H LXI H 0870H 21 xx 08 70 xx
70
08
0004H MOV A, L 7D 70 08 70 xx
0005H MOV B, H 44 70 08 70 08
0006H ADD B 80 78 08 70 08
0007H ADD A 87 F0 08 70 08
0008H HLT 76 F0 08 70 08
ADDRESSING MODES
These are the various techniques used to specify the data or addresses to be operated on by the instruction.
8085 microprocessor has the following address modes: direct, register, indirect, immediate and implied.
1. Direct addressing mode
The address of the operand is specified in the instruction itself. E.g. LDA 2000H, SHLD 3000H etc.
2. Register addressing mode
The source, destination operand or both are contained in the µP register. E.g. MOV A, B; SPHL, ADD C etc.
3. Register Indirect addressing mode
The memory address where the data is located is specified by the contents of a register pair. E.g. LDAX B,
MOV M, A etc.
4. Immediate addressing mode
The 8 or 16-bit data is specified as part of the instruction. E.g. MVI A, 20H, MVIM 30H, LXI SP, 2700H,
LXI D, 10FFH. Etc.
5. Implied/implicit addressing mode:
The opcode specifies the address of the operands. E.g. CMA, RAL etc.
6. Relative addressing mode
The address field of the instruction is added to the contents of program counter (PC) to evaluate the effective
address. E.g. JR 20H Address = PC +20
7. Absolute addressing mode
The address of data is part of the instruction. E.g. SHLD, LDA 2000H, LHLD, STA 4000H etc.
8. Indexed addressing mode
The contents of an index register is added to the address part of an instruction to obtain the effective addressing
mode. E.g. ADD A, (I X + 5) I X = Index Register
9. Stack addressing mode:
© N. Koech 2021 Microprocessor Systems 1st Ed.
Instruction consists of action (e.g. PUSH or POP) and register or actual data being sent or retrieved from stack.
E.g. PUSH B, POP D etc.
START = 4000
DATA 1 = 02
DATA 2 = 03
MEM = 6000
LOOP = 4002
COUNT = 0A
© N. Koech 2021 Microprocessor Systems 1st Ed.
v. Number of bytes
400E
4000
+ 1
000F
Flow charts
It is a diagrammatic method of writing a program. Unless a program is relatively easy, it is always advisable to
draw a flow chart first. When drawing flow charts, some standard symbols are used as shown below:
Name Symbol Meaning
1. Arrow - It indicates the direction of program execution.
of a program or segment.
Start
Program
- Clear the accumulator
- Move count 19H to register B
XRA A
MVI B, 19H
- Add contents of A to B
- Decrement count (register B) LOOP: ADD B
DCR B
JNZ LOOP
Is count HLT
Zero?
NO
YES
Stop
SUBROUTINES
It is a program which is used to carry out a similar sub-task like addition, subtraction, multiplication etc.
Subroutines are applicable in cases where a sequence like addition may be required several times within a
program. It will be better to write a subroutine which is called every time the addition sequence is require, other
than writing addition sequence every time addition is needed. Below shows a flow diagram of a main program
and a subroutine. Subroutine
Main Program JOE
CALL JOE
Nested subroutines
It is where a subroutine calls another subroutine. The LIFO (Last In First Out) always ensures that the correct
address is on top of stack memory when RET instruction is executed.
Nested subroutines are used when solving related problems such as determination of cosec x sin x. Where one
subroutine will find sin x while the other will find cosec x of the result obtained.
Nested subroutine is also used in time delay required between processes.
Below show a diagram of a nested subroutine.
Main Program PAT SAM
Subroutine
for sin x
Find cosec x sin x Subroutine
for cosec x
CALL PAT CALL SAM
RET RET
Parameter passing
The values operated on by a subroutine commonly known as parameters or augments may clearly change every
time the subroutine is called. For instance, for a subroutine that carries out addition between two values, the
values to be added may change each time the subroutine is called. Therefore, there should be a mechanism of
sending or passing these parameters to the subroutine for processing and also a way of getting back the results
obtained.
Note that subroutine does not contain values (parameters) but these values are held in the main program but are
pasted to the sub routine for processing.
Advantages of subroutine
i. It saves on memory by enhancing short programs through avoiding repetition of similar programs
ii. Encourages modular programming – where a large program is subdivided into module (subroutines)
to be developed and tested by different programmers.
iii. It is easier to modify a subroutine rather than a program sequence that appears severally in a main
program.
© N. Koech 2021 Microprocessor Systems 1st Ed.
Disadvantages of subroutine
i. Two more instructions are added into the instruction set: CALL and RET.
ii. Programs with some subroutines are complex to develop.
iii. Programs with some subroutines runs slower.
NB Since subroutine requires use of the stack memory, the stack memory must first be
initialized to become usable. This is done by loading the stack pointer SP with the higher address of the given
stack range. E.g. given the stack range 3000H – 40FFH, the SP is loaded with address 40FF as:
LXI SP, 40FFH
Example
i. Write a program in assembly language to add two values 06H and 39H and store the result in
memory address 7000H.
ii. Convert the program into a main program and a subroutine. Assume that the stack memory has the
range 3000H to 5FFFH.
iii. Write a main program utilizing the above subroutine to add values 45H and D8H and store the sum
in memory address 8000H.
Soln.
i. MVI A, 06H MVI A, 06H
MVI B, 39H OR
MVI B, 39H
ADD B ADD B
STA 7000H LXI H, 7000H
HLT MOV M, A
HLT
Interrupts are the signals generated by the external devices to request the microprocessor to perform
a task. There are 5 interrupt signals in intel 8085, i.e. TRAP, RST 7.5, RST 6.5, RST 5.5, and INTR.
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. 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.
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, and 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.
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 − 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.
Interrupt Service Routine (ISR)
A small program or a routine that when executed, services the corresponding interrupting source is
called an ISR.
TRAP
It is a non-maskable interrupt, having the highest priority among all interrupts. By default, 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
The main job of the interrupt system is to identify the source of the interrupt.
There is also a possibility that several devices will request simultaneously for CPU
communication. Then, the interrupt system has to decide which device is to be
serviced first.
Priority Interrupt
A priority interrupt is a system which decides the priority at which various
devices, which generates the interrupt signal at the same time, will be serviced by
the CPU. The system has authority to decide which conditions are allowed to
interrupt the CPU, while some other interrupt is being serviced. Generally, devices
with high speed transfer such as magnetic disks are given high priority and slow
devices such as keyboards are given low priority.
When two or more devices interrupt the computer simultaneously, the computer
services the device with the higher priority first.
Hardware Interrupts
When the signal for the processor is from an external device or hardware then
this interrupts is known as hardware interrupt.
Let us consider an example: when we press any key on our keyboard to do some
action, then this pressing of the key will generate an interrupt signal for the
processor to perform certain action. Such an interrupt can be of two types:
Maskable Interrupt
The hardware interrupts which can be delayed when a much high priority
interrupt has occurred at the same time.
Software Interrupts
The interrupt that is caused by any internal system of the computer system is
known as a software interrupt. It can also be of two types:
Normal Interrupt
The interrupts that are caused by software instructions are called normal
software interrupts.
Exception
In daisy chaining system all the devices are connected in a serial form. The
interrupt line request is common to all devices. If any device has interrupt signal
in low level state then interrupt line goes to low level state and enables the
interrupt input in the CPU. When there is no interrupt the interrupt line stays in
high level state. The CPU respond to the interrupt by enabling the interrupt
acknowledge line. This signal is received by the device 1 at its PI input. The
acknowledge signal passes to next device through PO output only if device 1 is
not requesting an interrupt.
The following figure shows the block diagram for daisy chaining priority system.
Advantages of DMA
i. Since it transfer data directly to and from memory it relieves congestion on the bus system.
ii. Very fast
iii. It relieves CPU from undertaking I/O operation.
Disadvantages of DMA
i. Complex to both implement and program
ii. Requires extra circuitry
iii. May block CPU from responding to urgent interrupts.
DMA Operations:
i. Read Operation: to transfer data from memory to an I/O device.
ii. Write Operation: to transfer data from an I/O device to memory.
iii. Verify Operation: to check the validity of the data that has been transferred.
Data bus (D0 – D7) – are bidirectional tri-state signals connected to the system data bus.
Address bus (A0 – A3 and A4 – A7) A0 – A3 are bidirectional tri-state signals.
Address strobe (ADATB) – this is used to demultiplex higher byte address and data using external latch. It
functions like ALE in 8085.
Address Enable (AEN):
it is active high. It enables 8-bit latch containing upper 8 address bits onto the system address bus. It is used to
take control of the address bus from the CPU.
DMA Channels
8257 has four identical channels: CH0 to CH4. Each channel has two sixteen bit registers:
i. DMA address register
ii. Terminal count register
DMA address register
It specifies the address of the first memory location to be accessed.
A14 A13 A12 A11 A10 A9 A8 A7 --- A0
Priority Resolver
It resolves peripheral requests. We have two modes of priorities:
i. Fixed priority mode
Channel 0 has the highest priority and channel 3 has the lowest.
During the DMA active cycle, data is transferred in the following modes:
i. Burst mode/ Block transfer mode:
In this mode, the entire block of data is transferred in one contiguous sequence. Once the DMA controller is
granted access to the system bus by the CPU, it transfers all the bytes of data in the data block before releasing
control of the system buses back to the CPU.
Disadvantages:
It renders the CPU inactive for long periods of time
ii. Cycle stealing mode/ Single transfer mode
Serial mode of data transfer can be divided into three groups namely:
i. Simplex method
ii. Half duplex method
iii. Duplex (full duplex) method.
Simplex mode:
Data flows on a single channel only in one direction. (Unidirectional). E.g. in radio and TV.
Transmitter Receiver
Channel
Bus Rx Serial
Buffer data
TXDR
Transmitter
Tx
© N. Koech 2021 Microprocessor Systems 1st Ed.
Interfacing UART with 8085 Microprocessor
Rx/Tx Rx/Tx
Rx/Tx Rx/Tx
Intel TxC/RxC TxC/RxC
UART
8085 Reset Reset
µP CLK CLK
RD RD
WR WR
D0 D0
D7 D7
CLK CLK
RS 232C Standard
Received data
Data 3 3 Data
Terminal Communication
Signal Ground
Equipment 7 7 Equipment1st Ed.
© N. Koech 2021 Microprocessor Systems
IEEE 488 Standard
It is a document that indicate the rules and specifications that an instrument connected to the bus must adhere to.
It consists of 16 lines. The lines are divided into three groups:
1. Data lines (8) – carry data, address and universal commands.
2. Hand shake lines (3) – are required because of asynchronous nature of operation of the bus.
3. Bus management lines (5) – ensure an orderly flow of data across the bus interface.
There are four categories of instruments that can be connected to an IEEE 488 bus. These are:
1. Listeners: are those instruments which receive data. E.g. a printer or a recorder.
2. Talkers: send data to listeners e.g. a digital voltmeter.
3. Talkers/listeners: are able to receive or send data. E.g. digital multi-meter, network analyzers etc.
4. Controllers: Manages all operations of the instrument connected to it and direct data flow from one to
another. E.g. a computer or a programmable calculator
Text editor
It is a software program used to create/type, modify source programs. It runs interactively with the user. It is
used for making corrections during program development. It helps the user to construct an assembly language
program in the right format.
Assembler
It is a program that converts assembly language instruction into corresponding machine language instruction.
It also assigns appropriate values to labels and symbols. It also checks syntax errors and provide error messages.
It enables software application developer to access, operate and manage a computer’s hardware architecture and
components.
Types of assemblers
i. Load and go iv. Macro-assembler vii. Meta-assembler
ii. One pass v. Cross assembler
iii. Two pass vi. Resident assembler
Load and go assembler
It is the simplest assembler program. It accepts as input a program whose instructions are essentially one to one
correspondence with those of the machine language, but with symbolic codes used for op-codes and operands.
The output of the assembler is the machine language, which is loaded directly in memory and executed.
One pass module assembler
This assembler goes through an assembly language program once and translates it into a machine language
program. It is suitable for small machines.
Two pass module assembler
It scans an assembly language program twice. In the first pass, it creates a symbol table (consists of labels and
addresses assigned to them). On the second pass, the assembler translates the assembly language into machine
code. It is more desirable and much easier to use.
Macro-assembler
It translates a program written in macro-language into machine language.
A macro is a group of instructions that perform one task.
Start
Define problem
Develop algorithm
Any
error?
External
system?
Any
error?
Use emulator
Use debugger tools for errors
tools for errors
Stop
Instruction interpretation
The control unit reads (fetches) an instruction from the memory address by the contents of the program counter
into the instruction register.
The control unit inputs the contents of the instruction register it recognizes the instruction type, obtains the
necessary operands and routes them to the appropriate functional units (registers and ALU).
The control unit then issues the necessary signals to execution unit to perform the desired operation and routes
the results to the destination specified.
Instruction sequencing
The control unit generates the address of the next instruction to be executed and loads it into the program
counter (PC).
User requirements
Product specification
In - Circuit Emulation
ICE
Implementation
(Prototype tests)
The designer will get the system requirements from the client.
From the requirements, he will come up with the product specifications. This will consist of both hardware and
software specifications. The development of both hardware and software are done simultaneously.
In-circuit emulation (ICE) is crucial as it provides the necessary support to help in testing either hardware
and/or software development before the prototype board is ready for testing.
It consist of selecting suitable devices to meet the system requirements. E.g. memory capacity, timing, power
rating, speed etc.
These devices are interconnected together using a breadboard for testing. The final circuit is built on a printed
circuit board (PCB).
Microprocessor Development System (MDS)
It is a laboratory equipment that consist of peripherals, large capacity memories, mass storage medium e.g.
floppy disks, printers, CRT etc.
It is very costly.
It also provide facility of software debugging.
Other hardware design aids
Teletype writers: comprises of a keyboard, printer etc.
Floppy disks
Compact disks
Pen drives
Magnetic tapes
EPROM programmer:
It is used to ‘burn’ experimental programs into the EPROM. The IC to be programmed is inserted into the
EPROM programmer and voltage levels varied to create a logic ‘0’ or ‘1’ into each cell being programmed.
UV- eraser:
It is used to delete experimental programs on the EPROM. It produces ultra-violet light which is shone through
a window into the EPROM cells. These UV energy erases any previous program.
Software design
The software is designed in assembly language. The program is entered in a development system by means of a
keyboard, after testing the software is debugged and then translated into machine language, corresponding to
the microprocessor used in the system, by means of a cross-assembler. It is then tested on the microprocessor
system built on the breadboard.
Software development aids
They include:
Assembler/cross assembler
Emulator
Compiler
Debugger
Loaders
Linkers
Text editors etc.
© N. Koech 2021 Microprocessor Systems 1st Ed.
In-Circuit Emulator (ICE) Board.
The ICE is designed to emulate the microprocessor being used in the system under development.
The ICE reads the program from the targeted system memory and then generates the correct bus signals during
execution.
It keeps a record in the MDS RAM of the sequence of actions of the targeted processor – which can be
examined later to locate any possible errors.
ICE substitutes the prototype CPU, memory and I/O ports at different stages of the prototype development.
Advantages / features of ICE
i. It allows downloading: programs can be transferred between software development system or
computer and the emulator.
ii. It allows resource sharing: the system under test can share emulator memory and I/O ports.
iii. It can be used as a debugging tool for troubleshooting in program.
Operating system
It is a system software that manages computer hardware and software resources.
It acts as an interface between software and hardware.
Types of operating systems
DOS
Windows
Linux
Start
Physically inspect the system for any obvious defects and faults
No
OK? Locate and rectify fault
Yes
Observe and measure power supply, clock,
bus activity, reset, hold, ready, R/W etc.
No
OK? Locate and rectify fault
Yes
Free run system. Check address bus pattern.
No
OK? Locate and rectify fault
Yes
Test memory, decoder, I/Os
No
OK? Locate and rectify fault
Yes
Stop
Certain test equipment have been devised to enable fault to be more readily isolated in digital and
microprocessor based system. The equipment include:
1. Logic probes
It is a hand held instrument which is used to detect and indicate High and Low logic test levels in all types of
logic circuit including TTL and CMOS. Logic probes have lamp indicators. Power for the logic probe is
normally taken from the circuit under test. The probe can also be used to detect open and short circuits.
2. Logic pulser
It is a hand held instrument which is used to stimulate digital circuit by injection of controlled pulses. It can
generate a short duration pulses manually by pressing a push button. In use, the pulse tip is applied to the circuit
node and a button is pressed on the pulse body to generate the pulse. You can apply pulses at one point in a
circuit with the pulser and check another point for resulting pulses with a logic probe.
3. Current tracer
It is used to detect a changing current in a wire or a printed circuit board track without breaking the circuit. It is
normally used to locate the source of a low impedance path (short circuit).
4. Cathode Ray Oscilloscope (CRO)
It is a laboratory equipment that consist of peripherals, large capacity memories, mass storage medium and
facility for debugging. The CRT edits the input data and debugs programs.
The CRT terminal has a keyboard for inputting and the monitor may be operated in local or line mode.
In line-mode, the CRT displays the data from the computer. In local mode, the computer is disconnected from
the monitor and this terminal has its own microprocessor to control its operation.
CRO
It consists of five main parts:
i. Electron gun: Source of accelerated, energized and focused beam of electrons.
ii. Deflection system: vertical and horizontal for sweeping the beam.
iii. Fluorescent screen: consists of phosphorus layer that glows when electron beam strikes it.
iv. Glass envelop
v. Base: for amplifying electron beam.
5. Logic Analyser
It is a multi-trace digital oscilloscope designed for use with microprocessor based system. The timing
relationships of several signals can be observed with respect to a triggering event. It displays data in
hexadecimal or binary format. It has a 40 pin probe and auxiliary probe to gather information and it has a RAM
to store data from the prototype, a ROM to store instructions related to the logic analyser and a microprocessor
to monitor the data gathering. A keyboard is provided to enter data in Hex or octal format and specify
operations. It samples the real-time information at a specific trigger and stores it in its RAM to display on the
CRT.
ROM Testing
Block diagram
Reference
ROM
under ROM
test EN
EN
Start
Compare data
No Indicate fault
Do data bytes agree?
Yes
Next address No
Last address?
n = n+1
Yes
Stop
The checksum test can be implemented with a special test instrument or it can be written as a sub-routine
program. The ROM test routine is automatically run on system start-up.
Start
Set n = 0
Set sum = 0
Read address n
Next address No
Last address?
n = n+1
Yes
Read checksum address
No
Do they agree? Indicate fault
Yes
Stop
RAM Testing
Start
No
All ok? Indicate fault
Yes
Reverse the pattern at all addresses
No
All ok? Indicate fault
Yes
Set n = 0
No
All ok? Indicate fault
Yes
No
Next address
Stop
Last address?
n = n+1
Yes
Stop
© N. Koech 2021 Microprocessor Systems 1st Ed.