LMECE315

27
1 LABORATORY MANUAL ECE 315 MICROPROCESSOR BASED SYSTEM DESIGN LABORATORY

Transcript of LMECE315

Page 1: LMECE315

1

LABORATORY MANUAL

ECE 315

MICROPROCESSOR BASED SYSTEM

DESIGN LABORATORY

Page 2: LMECE315

2

TABLE OF CONTENTS

S. No. Title of the Experiment Page No.

1

Perform the following using 8085 Simulator and 8085

Microprocessor kit in assembly language: (i).Write a program to

add two 8-bit numbers. (Or) Write a program to add two 16- bit

numbers. (ii) Write a program to subtract two 8-bit numbers. (Or)

Write a program to subtract two 16-bit numbers.

3

2

Perform the following using 8085 Simulator and 8085

Microprocessor kit in assembly language: (i) Write a program to

multiply two 8 bit numbers by repetitive addition method (Or)

Write a program to multiply two 8 bit numbers by rotation method.

(ii)Write a program to divide 16-bit number by 8-bit number.

7

3

Perform the following using 8085 Simulator and 8085

Microprocessor kit in assembly language: (i) Finding 1’s and 2’s

complement of an 8-bit number.(ii) Finding 1’s and 2’s

complement of an 16-bit number.

11

4

Perform the following using 8085 Simulator and 8085

Microprocessor kit in assembly language: (i) Write a program to

count number of 1’s in a program. (ii) Split hex data into two

nibbles and swap the higher nibble and lower nibble of that

number.

15

5 Write a program to convert a 2-digit BCD number into its binary

equivalent number. 17

6

Perform the following using 8085 Simulator and 8085

Microprocessor kit in assembly language: (i) Write a program for

displaying BCD down counter. Counter should count numbers from

99 to 00 and it should increment after every 1 sec. (ii) Write a

program for displaying binary up counter. Counter should count

numbers from 00 to FFH and it should increment after every 0.5

sec.

19

7 Interfacing of Seven segment display with 8085 microprocessor. 21

8 Interfacing of D/A converter with 8085 microprocessor to generate

RAMP wave. 23

9 Interfacing and control of stepper motor using 8085

microprocessor. 25

10 Design 8085 Microprocessor based Traffic light control. 26

Page 3: LMECE315

3

Experiment 1

1. Aim: Perform the following using 8085 Simulator and 8085 Microprocessor kit in

assembly language:

i. Write a program to add two 8-bit numbers. (Or) Write a program to add two 16-

bit numbers.

ii. Write a program to subtract two 8-bit numbers. (Or) Write a program to subtract

two 16-bit numbers.

Equipment required: 8085 microprocessor kit

2. Learning Objective:

a. To acquaint with 8085 microprocessor performance.

b. To determine the addition and subtraction of two numbers.

3. Program

Program ( i.a ):

Program (i.b):

Page 4: LMECE315

4

Program ( ii.a):

Page 5: LMECE315

5

Program ( ii.b ):

Page 6: LMECE315

6

4. Required Results:

Input: 1st number: ………….

2nd

number: …………

Output: Addition of two numbers: ……….

Subtraction of two numbers: ……..

5. Cautions:

a. Before enter the program press RST key on 8085 kit.

b. Proper care must be taken while handling the microprocessor kit.

6. Learning outcomes: Mathematical operations using 8085 kit.

Page 7: LMECE315

7

Experiment 2

1. Aim: Perform the following using 8085 Simulator and 8085 Microprocessor kit in

assembly language:

i. Write a program to multiply two 8 bit numbers by repetitive addition method

(or) write a program to multiply two 8 bit numbers by rotation method.

ii. Write a program to divide 16-bit number by 8-bit number.

Equipment required: 8085 Microprocessor kit.

2. Learning Objective:

a. To acquaint with 8085 microprocessor performance.

b. To determine the division and multiplication of two numbers.

3. Program

Program (i.a):

Page 8: LMECE315

8

Program ( i.b):

Page 9: LMECE315

9

Program (ii):

MVI E, 00 : Quotient = 0

LHLD 2200H : Get dividend

LDA 2300 : Get divisor

MOV B, A : Store divisor

MVI C, 08 : Count = 8

NEXT: DAD H : Dividend = Dividend x 2

MOV A, E

RLC

MOV E, A : Quotient = Quotient x 2

MOV A, H

SUB B : Is most significant byte of Dividend > divisor

JC SKIP : No, go to Next step

MOV H, A : Yes, subtract divisor

INR E : and Quotient = Quotient + 1

SKIP:DCR C : Count = Count - 1

JNZ NEXT : Is count =0 repeat

MOV A, E

STA 2401H : Store Quotient

Mov A, H

STA 2410H : Store remainder

HLT : End of program.

Page 10: LMECE315

10

4. Required Results:

Input: 1st number: ………

2nd

number: ………

Output: Multiplication of two numbers: …….

Division of two numbers: ……..

5. Cautions:

a. Before enter the program press RST key on 8085 kit.

b. Proper care must be taken while handling the microprocessor kit.

6. Learning outcomes: Mathematical operations using 8085.

Page 11: LMECE315

11

Experiment 3

1. Aim: Perform the following using 8085 Simulator and 8085 Microprocessor kit in

assembly language:

i. Finding 1’s and 2’s complement of an 8-bit number.

ii. Finding 1’s and 2’s complement of an 16-bit number.

Requirements: 8085 Microprocessor kit.

2. Learning Objective: Complement of a number using 8085 kit.

3. Assembly language:

Program (i.a):

Program (i.b):

Page 12: LMECE315

12

Explanation:

This program finds the 2’s complement of an 8-bit number stored in memory location

3000H.

Let us assume that the operand stored at memory location 3000H is 85H.

The operand is moved to accumulator from memory location 3000H.

Then, its complement is found by using CMA instruction.

One is added to accumulator by incrementing it to find its 2’s complement.

The result is stored at memory location 3001H.

Program (ii.a):

Explanation:

This program finds the 1’s complement of 16-bit number stored in memory 3000H-

3001H.

There is no direct way to find 1’s complement of 16-bit number. Therefore, this can be

accomplished by finding the 1’s complement of two 8-bit numbers.

Let us assume that the operand stored at memory locations 3000H-3001H is 45H-6AH.

The operand is loaded into H-L pair from memory locations 3000H-3001H.

The lower-order is moved from register L to accumulator.

Its complement is found by using CMA instruction.

The result obtained is moved back to register L.

Then, the higher-order is moved from register H to accumulator.

Its complement is found by using CMA instruction.

The result obtained is moved back to register H.

Now, the final result is in H-L pair.

Page 13: LMECE315

13

The result is stored from H-L pair to memory locations 3002H-3003H.

Program (ii.b):

Explanation:

This program finds the 2’s complement of 16-bit number stored in memory

locations 3000H- 3001H.

There is no direct way to find 2’s complement of 16-bit number. Therefore, this

can be accomplished by finding the 1’s complement of two 8-bit numbers and

then incrementing it to get 2’s complement.

Let us assume that the operand stored at memory locations 3000H-3001H is 12H-

05H.

The operand is loaded into H-L pair from memory locations 3000H-3001H.

The lower-order is moved from register L to accumulator.

Its complement is found by using CMA instruction.

The result obtained is moved back to register L.

Then, the higher-order is moved from register H to accumulator.

Its complement is found by using CMA instruction.

The result obtained is moved back to register H.

H-L pair is incremented to get 2’s complement.

Now, the final result is in H-L pair.

The result is stored from H-L pair to memory locations 3002H-3003H.

4. Required Results:

Input: 8-bit number: ………

16-bit number: ………

Page 14: LMECE315

14

Output: 1’s and 2’s complement of 8-bit number: …….

1’s and 2’s complement of 16-bit number: …….

5. Cautions:

a. Before enter the program press RST key on 8085 kit.

b. Proper care must be taken while handling the microprocessor kit.

6. Learning outcomes: Student will be able to learn how to use logical instructions.

Page 15: LMECE315

15

Experiment 4

1. Aim: Perform the following using 8085 Simulator and 8085 Microprocessor kit in

assembly language:

i. Write a program to count number of 1’s in a program.

.

ii. Split hex data into two nibbles and swap the higher nibble and lower nibble of

that number.

Requirements: 8085 Microprocessor kit.

2. Learning Objective: Swapping of lower and higher nibble of a number.

3. Assembly language

Program ( i ) :

MVI B,00H

MVI C,08H

MOV A,D

BACK: RAR

JNC SKIP

INR B

SKIP: DCR C

JNZ BACK

HLT

Program ( ii ) :

LDA 2200H ; Get the packed BCD number

ANI F0H ; Mask lower nibble

RRC

RRC

RRC

RRC ; Adjust higher BCD digit as a lower digit

STA 2300H ; Store the partial result

LDA 2200H ; Get the original BCD number

ANI 0FH ; Mask higher nibble

STA 2301H ; Store the result

LDA 2300H ; Get the contents of memory location 2300H into accumulator

MOV B, A ; save the contents in B register

LDA 2301H ; Get the contents of memory location 2301H into accumulator.

STA 2300H ; Store the contents of accumulator at address 2000H.

MOV A, B ; Get the saved contents back into A register

STA 2301H ; Store the contents of accumulator at address 2200H

HLT ; Terminate program execution

Page 16: LMECE315

16

4. Required Results:

Input: Enter the number: ………

Output: number of one’s in number: …….

Result after swapping: …….

5. Cautions:

a. Before enter the program press RST key on 8085 kit.

b. Proper care must be taken while handling the microprocessor kit.

6. Learning outcomes: Students will be able to learn mathematical operations using

8085 kit.

Page 17: LMECE315

17

Experiment 5

1. Aim: Write a program to convert a 2-digit BCD number into its binary equivalent

number.

Requirements: 8085 Microprocessor kit.

2. Learning Objective: BCD to binary conversion of a number.

3. Program:

Sample problem:

(2200H) = 67H

(2300H) = 6 x OAH + 7 = 3CH + 7 = 43H

Sample Program:

LDA 2200H : Get the BCD number

MOV B, A : Save it

ANI OFH : Mask most significant four bits

MOV C, A : Save unpacked BCDI in C register

MOV A, B : Get BCD again

ANI FOH : Mask least significant four bits

RRC : Convert most significant four bits into unpacked BCD2

RRC

RRC

RRC

MOV B, A : Save unpacked BCD2 in B register

XRA A : Clear accumulator (sum = 0)

Page 18: LMECE315

18

MVI D, 0AH : Set D as a multiplier of 10

Sum: ADD D : Add 10 until (B) = 0

DCR B : Decrement BCD2 by one

JNZ SUM : Is multiplication complete? i if not, go back and add again

ADD C : Add BCD1

STA 2300H : Store the result

HLT : Terminate program execution

4. Required Results:

Input: Enter 2 digit BCD number: ………

Output: Equivalent binary number: …….

5. Cautions:

a. Before enter the program press RST key on 8085 kit.

b. Proper care must be taken while handling the microprocessor kit.

6. Learning outcomes: Student will be able to learn the use of stack pointer and subroutines.

Page 19: LMECE315

19

Experiment 6

1. Aim: Perform the following using 8085 Simulator and 8085 Microprocessor kit in assembly

language :

i. Write a program for displaying BCD down counter. Counter should count numbers from 99 to

00 and it should increment after every 1 sec.

ii. Write a program for displaying binary up counter. Counter should count numbers from 00 to

FFH and it should increment after every 0.5 sec.

Requirements: 8085 Microprocessor kit.

2. Learning Objective: Implementation of BCD down counter and Binary UP counter.

3. Program ( i ) :

LXI SP, 27FFH : Initialize stack pointer

MVI C, 99H : Initialize counter = 99

BACK:CALL Display : Call display subroutine

CALL Delay : Call delay subroutine

ADI 99H : See Addition below

DAA : Adjust for decimal

CPI 99H : Compare with last count

JNZ BACK :If no, repeat

HLT

Page 20: LMECE315

20

Program ( ii ) :

LXI SP, 27FFH : Initialize stack pointer

MVI C, OOH : Initialize counter

BACK: CALL Display : Call display subroutine

CALL Delay : Call delay subroutine

INR C : Increment counter

MOV A, C

CPI OOH : Check counter is > FFH

JNZ BACK : If not, repeat

HLT : Stop

Delay Routine:

Delay: LXI B, count : Initialize count

BACK: DCX D : Decrement count

MOV A, E

ORA D : Logically OR D and E

JNZ BACK : If result is not 0 repeat

RET : Return to main program

4. Cautions:

a. Before enter the program press RST key on 8085 kit.

b. Proper care must be taken while handling the microprocessor kit.

5. Learning outcomes: mathematical operations using 8085.

Page 21: LMECE315

21

Experiment 7

1. Aim: Interfacing of Seven segment display with 8085 microprocessor.

Requirements: 8085 Microprocessor kit, Seven Segment LED & wires.

2. Learning Objective: Seven segment interfacing using 8085 kit.

3. Circuit Diagram:

4. Program:

MVI A, 80H

OUT CR

K: LXI H, 2000H

MVI B, 10H

KK: MOV A, M

OUT PA

CALL DELAY

INX H

JNZ KK

Page 22: LMECE315

22

JMP K

HLT

Delay: LXI D, Count

Back: DCX D

MOV A, D

ORA E

JNZ Back

RET

5. Inputs:

2000: 40H, 79H, 24H, 30H, 19H, 12H, 02H, 78H, 00H, 18H, 08H, 03H, 46H, 21H, 06H,

0EH

6. Result:

On the Seven segment LED we can see all the Hexadecimal no’s displayed with some

delay as mentioned.

7. Cautions:

a. Before enter the program press RST key on 8085 kit.

b. Proper care must be taken while handling the microprocessor kit.

8. Learning outcomes: Students will be able to learn how to interface seven segment

with 8085.

Page 23: LMECE315

23

Experiment 8:

1. Aim: Interfacing of D/A converter with 8085 microprocessor to generate RAMP

wave.

Requirements: 8085 Microprocessor Kit, DAC0808, 100nF(2), 1k, Op-Amp 741.

2. Learning Objective: Digital to analog converter interfacing.

3. Circuit Diagram:

4. Program:

MOV A, 80H

OUT CW

MVI A, 00H

KK: OUT PA

CALL DELAY

INC A

JMP KK

RST 5

Delay: LXI D, Count

Back: DCX D

MOV A, D

ORA E

JNZ Back

RET

Page 24: LMECE315

24

5. Result: On the CRO we can see a RAMP wave generated.

6. Cautions:

a. Before enter the program press RST key on 8085 kit.

b. Proper care must be taken while handling the microprocessor kit.

7. Learning outcomes: Students will be able to learn how to interface digital to analog

converter with 8085.

Page 25: LMECE315

25

Experiment 9

1. Aim: Interfacing and control of stepper motor using 8085 microprocessor.

Requirements: 8085 Microprocessor kit, Stepper Motor, Motor driver circuit

(ULN2003) & wires.

2. Learning Objective: Stepper motor interfacing with 8085.

3. Program:

i) To rotate in Clock Wise direction

MVI A, 80H

OUT CR

MVI A, 44H

KK: OUT PA

CALL DELAY

RRC

JMP KK

RST 5

ii) To rotate in Anti-Clock Wise direction

MVI A, 80H

OUT CR

MVI A, 44H

KK: OUT PA

CALL DELAY

RLC

JMP KK

RST 5

Delay: LXI D, Count

Back: DCX D

MOV A, D

ORA E

JNZ Back

RET

4. Result: Stepper motor rotates in Clock wise & Anti-clock wise direction.

5. Cautions:

a. Before enter the program press RST key on 8085 kit.

b. Proper care must be taken while handling the microprocessor kit.

6. Learning outcomes: Students will be able to learn how to interface and control

stepper motor with 8085.

Page 26: LMECE315

26

Experiment 10

1. Aim: Design a 8085 Microprocessor based Traffic light control for figure shown

below with the following conditions:

Allow traffic to flow from N to S & S to N for 1sec

Glow all Yellow lights for 0.2sec

Allow traffic to flow from W to E & E to W for 1sec

Glow all Yellow lights for 0.2sec

Make this process continues.

Requirements: 8085 Microprocessor Kit, 9 LED’s, 5K resistors (9)

2. Learning Objective: Traffic light control system using 8085.

3. Circuit Diagram:

4. Program:

MVI A, 80H : Initialize 8255, port A and port B

OUT CR ;(CR) : in output mode

START: MVI A, 09H

OUT PA; (PA) : Send data on PA to glow R1 and R2

MVI A, 24H

OUT PB; (PB) : Send data on PB to glow G3 and G4

MVI C, 28H : Load multiplier count (40ıο) for delay

Page 27: LMECE315

27

CALL DELAY : Call delay subroutine

MVI A, 12H

OUT PA; PA : Send data on Port A to glow Y1 and Y2

OUT 81H ;PB : Send data on port B to glow Y3 and Y4

MVI C, 0AH : Load multiplier count (10ıο) for delay

CALL: DELAY : Call delay subroutine

MVI A, 24H

OUT 80H ;PA : Send data on port A to glow G1 and G2

MVI A, 09H

OUT 81H; PB : Send data on port B to glow R3 and R4

MVI C, 28H : Load multiplier count (40ıο) for delay

CALL DELAY : Call delay subroutine

MVI A, 12H

OUT 80H : Send data on port A to glow Y1 and Y2

OUT 81H : Send data on port B to glow Y3 and Y4

MVI C, 0AH : Load multiplier count (10ıο) for delay

CALL DELAY : Call delay subroutine

JMP START

Delay Subroutine:

DELAY: LXI D, Count : Load count to give 0.5 sec delay

BACK: DCX D : Decrement counter

MOV A, D

ORA E : Check whether count is 0

JNZ BACK : If not zero, repeat

DCR C : Check if multiplier zero, otherwise repeat

JNZ DELAY

RET : Return to main program

5. Cautions:

a. Before enter the program press RST key on 8085 kit.

b. Proper care must be taken while handling the microprocessor kit.

6. Learning outcomes: Students will be able to learn how to design microprocessor

based traffic light system using 8085.