LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

175
www.Vidyarthiplus.com www.Vidyarthiplus,com Page 1 EE2356 MICROPROCESSOR AND MICRO CONTROLLER LABORATORY 8-bit Microprocessor 1. Simple arithmetic operations: Multi precision addition / subtraction / multiplication / division. 2. Programming with control instructions: Increment / Decrement, Ascending / Descending order, Maximum / Minimum of numbers,Rotate instructions Hex / ASCII / BCD code conversions. 3. A/D Interfacing. 4. D/A Interfacing. 5. Traffic light controller interfacing 6. Steeper Motor Interfacing 7. Simple experiments using 8251, 8279, 8254. 16-bit Microprocessor 8. Simple arithmetic operations: Multi Precision addition / substraction/multiplication / division. 8-bit Microcontroller 9. Demonstration of basic instructions with 8051 Micro controller execution, including: a. Conditional jumps, looping b. Calling subroutines. c. Stack parameter testing 10. Interfacing Keyboard and Display 11. Stepper motor Interfacing\ a. D/A Interfacing b. Traffic light controller Interfacing c. 8051 based Serial Port Communication.

Transcript of LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

Page 1: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 1

EE2356 MICROPROCESSOR AND MICRO CONTROLLER LABORATORY

8-bit Microprocessor

1. Simple arithmetic operations: Multi precision addition / subtraction / multiplication

/ division.

2. Programming with control instructions: Increment / Decrement, Ascending /

Descending order, Maximum / Minimum of numbers,Rotate instructions

Hex / ASCII / BCD code conversions.

3. A/D Interfacing.

4. D/A Interfacing.

5. Traffic light controller interfacing

6. Steeper Motor Interfacing

7. Simple experiments using 8251, 8279, 8254.

16-bit Microprocessor

8. Simple arithmetic operations: Multi Precision addition / substraction/multiplication / division.

8-bit Microcontroller

9. Demonstration of basic instructions with 8051 Micro controller execution, including:

a. Conditional jumps, looping

b. Calling subroutines.

c. Stack parameter testing

10. Interfacing Keyboard and Display

11. Stepper motor Interfacing\

a. D/A Interfacing

b. Traffic light controller Interfacing

c. 8051 based Serial Port Communication.

Page 2: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 2

I (a). ADDITION OF TWO 8-BIT NUMBERS

AIM:

To perform 8-bit addition operation with carry using 8085 and to store the result in memory.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Start the program.

2. Load the first data in the accumulator.

3. Move the content of A to B register.

4. Load the second data in the accumulator.

5. Initialize the carry with zero.

6. Add the content of B register to the accumulator.

7. If the carry is “0” then store the result in address which is specified.

8. If the carry is “1” then increment the C register and store the result.

9. Stop the program.

Page 3: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 3

FLOW CHART:

NO

YES

STORE THE RESULT

STOP

INITIALIZE THE DATA

ADD DATA

IF

CARRY=0

Y

INCREMENT CARRY

START

Page 4: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 4

OBSERVATION:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

RESULT:

Thus the addition of two 8-bit numbers performed using 8085 Microprocessor and the output was stored in memory.

Page 5: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 5

I (a). ADDITION OF TWO 8-BIT NUMBERS

PROGRAM:

ADDRESS LABEL MNEMONICS HEX

CODE

COMMENTS

Page 6: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 6

9100

9103

9104

9107

9108

910A

910D

910E

9111

9112

9115

LDA 9200

MOV B,A

LDA 9201

ADD B

MVI C,00

INC 910E

INR C

STA 9600

MOV A,C

STA 9601

RST 1

3A,00,92

47

3A,01,92

80

0E,00

02,0E,91

0C

32,00,96

79

32,00,96

CF

Load the data in the accumulator

Move the content of A register to B

Load the second value in accumulator

Add the content of B to A

Initialize C register with 00

Jump on No carry to the specified

address

Increment the C register

Store the result in specified address

Move the content of C to accumulator

Store the carry in specified address

Terminate the process

Page 7: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 7

I (b). SUBTRACTION OF TWO 8-BIT NUMBERS

AIM:

To perform 8-bit subraction operation with carry using 8085 and to store the result in memory.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Start the program.

2. Load the first data in the accumulator.

3. Move the content of A to B register.

4. Load the second data in the accumulator.

5. Subtract the content of B register from the accumulator.

6. If the borrow is “0” then go to step 7.

7. Store the result.

8. Stop the program.

Page 8: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 8

FLOW CHART:

NO NO

YES

STORE THE RESULT

STOP

INITIALIZE THE DATA

ADD DATA

IF BORROW =0

INCREMENT BORROW

START

Page 9: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 9

OBSERVATION:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

RESULT:

Thus the subtraction of two 8-bit numbers performed using 8085 Microprocessor and the output was stored in

memory.

Page 10: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 10

I (b). SUBTRACTION OF TWO 8-BIT NUMBERS

PROGRAM:

ADDRESS LABEL MNEMONICS HEX

CODE

COMMENTS

Page 11: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 11

9100

9103

9104

9107

9108

910A

910D

910E

9111

9112

9115

LSB

LDA 9200

MOV B,A

LDA 9201

SUB B

MVI C,00

JNC 910E

INR C

STA 9300

MOV A,C

STA 9301

RST 1

3A,00,92

47

3A,01,92

90

0E,00

02,0E,91

0C

32,00,93

79

32,00,93

CF

Load the data in the accumulator

Move the content of A register to B

Load the second value in accumulator

Subtract the data

Move borrow as 00

Jump on No borrow to the specified

address

Increment the C register

Store the result in specified address

Move the content of C to accumulator

Store the carry in specified address

Terminate the process

I (c). MULTIPLICATION OF 8-BIT NUMBERS

AIM:

Page 12: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 12

To perform the 8-bit multiplication operation by using 8085 microprocessor.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Start the program.

2. Get the multiplier and multiplicand.

3. Initialize the carry register

4. Initialize count register with multiplier

5. Clear accumulator.

6. Add accumulator with multiplicand

7. If carry occurs increment the carry register.

8. Decrement the count register.

9. If zero go to step 1.

10. Else go to step 6.

11. Sore accumulator.

12. Store carry register.

13: Stop the program.

.

Page 13: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 13

FLOW CHART:

YES

NO

YES

NO

START

GET MULTIPLIER AND MULTIPLICANT

INITIALIZE COUNT REGISTER WITH MULTIPLIER

CLEAR THE ACCUMULATOR

ADD THE ACCUMULATOR CONTENT WITH MULTIPLIER

INITIALIZE A CARRY REGISTER

IF CARRY=0

INCREMENT CARRY REGISTER

DECREMENT COUNT

JUMP ON

NON ZERO

STORE THE RESULT

Page 14: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 14

I (c). MULTIPLICATION OF TWO 8-BIT NUMBERS

PROGRAM:

ADDRESS LABEL MNEMONICS HEX

CODE

COMMENTS

STOP

Page 15: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 15

9100

9103

9104

9107

9108

910A

910B

910C

910F

9110

9111

9114

9117

9118

911B

LDA 9200

MOV D,A

LDA 9201

MOV B,A

DCR D

MVI C,00

ADD B

JNC 9110

INR C

DCR D

JNZ 910B

STA 9600

MOV A,C

STA 9601

RST 1

3A,00,92

57

3A,01,92

47

15

0E,00

80

D2,10,91

0C

15

C2,0B,91

32,00,96

79

32,01,96

CF

Load the data in the accumulator

Move the content of A register to D

Load the second value in accumulator

Move the content of A register to B

Clear the accumulator

Add register D to A

Jump on no carry

Jump on no zero

Store the result in specified address

Move the content of C to accumulator

Store the carry in specified address

Terminate the process

Page 16: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 16

OBSERVATION:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

RESULT:

Thus the multiplication of two 8-bit numbers performed using 8085 Microprocessor and the output was

stored in memory

Page 17: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 17

I(d). DIVISION OF 8-BIT NUMBERS

AIM:

To perform the 8-bit division operation by using 8085 microprocessor.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Start the program.

2. Get the divisor and dividend.

3. Initialize count register with divisor

4. Clear accumulator.

5. Move the dividend into accumulator

6. Subtract divisor from accumulator.

7. Increment the count register.

8. Compare accumulator with divisor.

9. If division is less go to step 5 else to next step.

10. Stop the program.

Page 18: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 18

FLOW CHART:

START

LOAD TEHE DATA AND INITIALIZE THE COUNT O

MOVE THE COUNT OF A TO B

SUBTRACT B FROM A

GET THE DIVISOR INTO A

INCREMENT C

COMPARE B WITH C

IF NO ZERO

STORE THE A

MOVE C TO A

Page 19: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 19

I(d). DIVISION OF 8-BIT NUMBERS

PROGRAM:

Address Label Mnemonics Hex

Code

Comments

STORE A

Page 20: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 20

9100

9103

9104

9107

9109

910A

910B

910C

910F

9112

9113

9116

LDA 9200

MOV D,A

LDA 9201

MVI C,00

SUB D

INR C

CMP D

JNC 9109

STA 9600

MOV A,C

STA 9601

RST 1

3A,00,92

57

3A,01,92

0E,00

92

0C

BA

D2,09,91

32,00,96

79

32,01,96

CF

Load the dividend in the accumulator

Move the content of A register to D

Load the second value in accumulator

Get the divisor

Subtract D from A

Increment C

Compare C and D

Jump on no zero

Store the result in specified address

Move the content of C to accumulator

Store the carry in specified address

Terminate the process

Page 21: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 21

OBSERVATION:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

RESULT:

Thus the division of two 8-bit numbers performed using 8085 Microprocessor and the output was stored in memory.

Page 22: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 22

II. (a). LARGEST ELEMENT IN AN ARRAY

AIM:

To find the largest element in an array.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Place all the elements of an array in the consecutive memory locations.

2. Fetch the first element from the memory location and load it in the accumulator.

3. Initialize a counter (register) with the total number of elements in an array.

4. Decrement the counter by 1.

5. Increment the memory pointer to point to the next element.

6. Compare the accumulator content with the memory content (next element).

7. If the accumulator content is smaller, then move the memory content (largest element) to the accumulator. Else

continue.

8. Decrement the counter by 1.

9. Repeat steps 5 to 8 until the counter reaches zero

10. Store the result (accumulator content) in the specified memory location.

Page 23: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 23

FLOW CHART:

NO

YES

[B] � 04H

[HL] � [8100H]

[A] � [HL]

[HL � [HL] + 1

IS

[A] < [HL]?

[A]� [HL]

[8105] � [A]

START

[B] � [B]-1

IS

[B] = 0?

Page 24: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 24

PROGRAM:

ADDRESS OPCODE LABEL MNEM

ONICS

OPER

AND

COMMENTS

8001 21,00,81 LXI H,8100 Initialize HL reg. to

8100H

8004 06,04 MVI B,04 Initialize B reg with no. of

comparisons(n-1)

8006 7E MOV A,M Transfer first data to acc.

8007 23 LOOP1 INX H Increment HL reg. to point next

memory location

8008 BE CMP M Compare M & A

8009 D2,0D,80 JNC LOOP If A is greater than M then go to

loop

800C 7E MOV A,M Transfer data from M to A reg

800D 05 LOOP DCR B Decrement B reg

800E C2,07,80 JNZ LOOP1 If B is not Zero go to loop1

STOP

Page 25: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 25

8011 32,05,81 STA 8105 Store the result in a memory

location.

8014 76 HLT Stop the program

OBSERVATION:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

8100 8105

8101

8102

8103

8104

RESULT:

Page 26: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 26

Thus the largest number in the given array is found out.

II. (b) SMALLEST ELEMENT IN AN ARRAY

AIM:

To find the smallest element in an array.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Place all the elements of an array in the consecutive memory locations.

Page 27: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 27

2. Fetch the first element from the memory location and load it in the accumulator.

3. Initialize a counter (register) with the total number of elements in an array.

4. Decrement the counter by 1.

5. Increment the memory pointer to point to the next element.

6. Compare the accumulator content with the memory content (next element).

7. If the accumulator content is smaller, then move the memory content (largest element) to the accumulator. Else

continue.

8. Decrement the counter by 1.

9. Repeat steps 5 to 8 until the counter reaches zero

10. Store the result (accumulator content) in the specified memory location.

FLOW CHART:

[B] � 04H

[HL] � [8100H]

START

Page 28: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 28

YES

NO

NO

YES

ADDRE

SS

OPCO

DE

LABEL MNEM

ONICS

OPER

AND

COMMENTS

[A] � [HL]

[HL � [HL] + 1

IS

[A] < [HL]?

[A]� [HL]

[8105] � [A]

[B] � [B]-1

IS

[B] = 0?

STOP

Page 29: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 29

PROGRAM:

8001 21,00,81 LXI H,8100 Initialize HL reg. to

8100H

8004 06,04 MVI B,04 Initialize B reg with no. of

comparisons(n-1)

8006 7E MOV A,M Transfer first data to acc.

8007 23 LOOP1 INX H Increment HL reg. to point next

memory location

8008 BE CMP M Compare M & A

8009 DA,0D,8

0

JC LOOP If A is lesser than M then go to

loop

800C 7E MOV A,M Transfer data from M to A reg

800D 05 LOOP DCR B Decrement B reg

800E C2,07,80 JNZ LOOP1 If B is not Zero go to loop1

8011 32,05,81 STA 8105 Store the result in a memory

location.

8014 76 HLT Stop the program

Page 30: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 30

OBSERVATION:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

8100 8105

8101

8102

8103

8104

RESULT:

Thus the smallest number in the given array is found out.

Page 31: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 31

II. (c ). ASCENDING ORDER

AIM:

To sort the given number in the ascending order using 8085 microprocessor.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Get the numbers to be sorted from the memory locations.

2. Compare the first two numbers and if the first number is larger than second then interchange the number.

3. If the first number is smaller, go to step 4.

4. Repeat steps 2 and 3 until the numbers are in required order.

Page 32: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 32

FLOWCHART:

[B] � 04H

[HL] � [8100H]

[A] � [HL]

[HL � [HL] + 1

IS

[A] < [HL]?

[D]� [HL]

[HL] � [A]

[C] � 04H

START

Page 33: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 33

YES

NO

NO

YES

NO

Y

YES

[HL] � [HL] - 1

[HL] � [D]

[HL] � [HL] + 1

[C] � [C] – 01 H

A

IS

[C] = 0?

A

[B] � [B]-1

IS

[B] = 0?

STOP

Page 34: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 34

PROGRAM:

ADD

RE

SS

OPCO

DE

LABE

L

MNEM

ONICS

OPER

AND

COMMENTS

8000 06,04 MVI B,04 Initialize B reg with number of

comparisons (n-1)

8002 21,00,81 LOOP

3

LXI H,8100 Initialize HL reg. to

8100H

8005 0E,04 MVI C,04 Initialize C reg with no. of

comparisons(n-1)

Page 35: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 35

8007 7E LOOP2 MOV A,M Transfer first data to acc.

8008 23 INX H Increment HL reg. to point next

memory location

8009 BE CMP M Compare M & A

800A DA,12,80 JC LOOP1 If A is less than M then go to

loop1

800D 56 MOV D,M Transfer data from M to D reg

800E 77 MOV M,A Transfer data from acc to M

800F 2B DCX H Decrement HL pair

8010 72 MOV M,D Transfer data from D to M

8011 23 INX H Increment HL pair

8012 0D LOOP1 DCR C Decrement C reg

8013 C2,07,80 JNZ LOOP2 If C is not zero go to loop2

8016 05 DCR B Decrement B reg

8017 C2,02,80 JNZ LOOP3 If B is not Zero go to loop3

801A 76 HLT Stop the program

OBSERVATION:

INPUT OUTPUT

MEMORY

LOCATION

DATA MEMORY

LOCATION

DATA

Page 36: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 36

8100 8100

8101 8101

8102 8102

8103 8103

8104 8104

RESULT:

Thus the ascending order program is executed and thus the numbers are arranged in ascending order.

III. (d). DESCENDING ORDER

AIM:

Page 37: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 37

To sort the given number in the descending order using 8085 microprocessor.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Get the numbers to be sorted from the memory locations.

2. Compare the first two numbers and if the first number is smaller than second then interchange the number.

3. If the first number is larger, go to step 4

4. Repeat steps 2 and 3 until the numbers are in required order

Page 38: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 38

FLOWCHART:

NO

YES

[B] � 04H

[HL] � [8100H]

[A] � [HL]

[HL � [HL] + 1

IS

[A] < [HL]?

[D]� [HL]

[HL] � [A]

[HL] � [HL] - 1

[HL] � [D]

[HL] � [HL] + 1

[C] � [C] – 01 H

A

[C] � 04H

START

Page 39: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 39

NO

YES

NO

YES

IS

[C] = 0?

A

[B] � [B]-1

IS

[B] = 0?

STOP

Page 40: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 40

PROGRAM:

ADDRE

SS

LABEL MNEM

ONICS

OPER

AND

OPCODE COMMENTS

8000 MVI B,04 06,04 Initialize B reg with number of

comparisons (n-1)

8002 LOOP 3 LXI H,8100 21 Initialize HL reg. to

8100H

8005 MVI C,04 0E,04 Initialize C reg with no. of

comparisons(n-1)

8007 LOOP2 MOV A,M 7E Transfer first data to acc.

8008 INX H 23 Increment HL reg. to point

next memory location

8009 CMP M BE Compare M & A

800A JNC LOOP1 D2,12,80 If A is greater than M then go

to loop1

800D MOV D,M 56 Transfer data from M to D reg

800E MOV M,A 77 Transfer data from acc to M

800F DCX H 2B Decrement HL pair

Page 41: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 41

8010 MOV M,D 72 Transfer data from D to M

8011 INX H 23 Increment HL pair

8012 LOOP1 DCR C 0D Decrement C reg

8013 JNZ LOOP2 C2,07,80 If C is not zero go to loop2

8016 DCR B 05 Decrement B reg

8017 JNZ LOOP3 C2,02,80 If B is not Zero go to loop3

8019

801A HLT 76 Stop the program

OBSERVATION:

INPUT OUTPUT

MEMORY

LOCATION

DATA MEMORY

LOCATION

DATA

8100 8100

8101 8101

8102 8102

8103 8103

8104 8104

RESULT:

Page 42: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 42

Thus the descending order program is executed and thus the numbers are arranged in descending order.

II.(e). CODE CONVERSION –DECIMAL TO HEX

AIM:

To convert a given decimal number to hexadecimal.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Initialize the memory location to the data pointer.

2. Increment B register.

3. Increment accumulator by 1 and adjust it to decimal every time.

4. Compare the given decimal number with accumulator value.

5. When both matches, the equivalent hexadecimal value is in B register.

6. Store the resultant in memory location.

Page 43: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 43

FLOWCHART:

START

HL 4500H

A 00

B 00H

Page 44: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 44

NO

YES

PROGRAM:

ADDRE

SS

OPCO

DE

LABEL MNEM

ONICS

OPER

AND

COMMENTS

8000 21 LXI H,8100 Initialize HL reg. to

A A +1

B B+1

A B

Is

A=M?

8101 A

Stop

Page 45: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 45

8001 00 8100H

8002 81

8003 3E MVI A,00 Initialize A register.

8004 00

8005 06 MVI B,00 Initialize B register..

8006 00

8007 03 LOOP INR B Increment B reg.

8008 C6 ADI 01 Increment A reg

8009 01

800A 27 DAA Decimal Adjust Accumulator

800B BE CMP M Compare M & A

800C C2 JNZ LOOP If acc and given number are not

equal, then go to LOOP 800D 07

800E 80

800F 78 MOV A,B Transfer B reg to acc.

8010 32 STA 8101 Store the result in a memory

location. 8011 01

8012 81

8013 76 HLT Stop the program

OUTPUT:

Page 46: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 46

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

8100 8101

RESULT:

Thus an ALP program for conversion of decimal to hexadecimal was written and executed.

Page 47: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 47

II. (f). CODE CONVERSION –HEXADECIMAL TO DECIMAL

AIM:

To convert a given hexadecimal number to decimal.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Initialize the memory location to the data pointer.

2. Increment B register.

3. Increment accumulator by 1 and adjust it to decimal every time.

4. Compare the given hexadecimal number with B register value.

5. When both match, the equivalent decimal value is in A register.

6. Store the resultant in memory location.

Page 48: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 48

FLOWCHART:

NO

YES

NO

YES

START

HL 8100H

A 00

B 00H

A A +1

Decimal adjust

accumulator

B B+1

D A, A B,

Is

A=M?

C 00H

C C+1

Is there

carry?

Page 49: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 49

PROGRAM:

ADD

RE

SS

OPCO

DE

LABEL MNEM

ONICS

OPER

AND

COMMENTS

8000 21,00,81 LXI H,8100 Initialize HL reg. to

8100H

8003 3E,00 MVI A,00 Initialize A register.

8005 06,00 MVI B,00 Initialize B register.

8007 0E,00 MVI C,00 Initialize C register for carry.

8009 04 LOOP INR B Increment B reg.

800A C6,01 ADI 01 Increment A reg

800C 27 DAA Decimal Adjust Accumulator

800D D2,11,80 JNC NEXT If there is no carry go to NEXT.

8010 0C INR C Increment c register.

8011 57 NEXT MOV D,A Transfer A to D

8012 78 MOV A,B Transfer B to A

8013 BE CMP M Compare M & A

8014 7A MOV A,D Transfer D to A

8015 C2,09,80 JNZ LOOP If acc and given number are not

equal, then go to LOOP

Stop

8101 A, A C

Page 50: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 50

8018 32,01,81 STA 8101 Store the result in a memory

location.

801B 79 MOV A,C Transfer C to A

801C 32,02,81 STA 8102 Store the carry in another

memory location.

801F 76 HLT Stop the program

OUTPUT:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

8100 8101

8102

RESULT:

Thus an ALP program for conversion of hexadecimal to decimal was written and executed.

Page 51: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 51

II. (f) PROGRAMMING WITH 8085 – CODE CONVERSION

AIM:

To write an assembly language program to convert BCD data to binary and binary to BCD using 8085

Microprocessor kit.

APPARATUS REQUIRED:

S.No APPARATUS QUANTITY

1 8085 Microprocessor Kit 1

2 Power Supply -

3 Opcode Sheet 1

Page 52: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 52

ALGORITHM FOR BCD TO BINARY CONVERSION:

1. Get the BCD data in A register and save in E register.

2. Mark the lower units of BCD data in A register.

3. Rotate the upper units to lower units’ position and save in B register.

4. Clear the accumulator.

5. Move 0AH to C register.

6. Decrement C register.

7. If zf=0, go to the previous step.

8. Add B register to A register.

9. Save the product in B register.

10. Get the BCD data in A register from E register and mark the upper nibble.

11. Add the units in A register with the product in B register.

12. Store the binary value in A register.

13.Stop the program.

FLOW CHART FOR BCD TO BINARY CONVERSION:

Page 53: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 53

Page 54: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 54

PROGRAM FOR BCD TO BINARY CONVERSION:

MEMORY

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

4100 START LXI H, 5100H 21,00,51

4103 MOV A,M 7E

4104 ANI 0F E6,0F

4106 MOV B,A 47

4107 MOV A,M 7E

4108 ANI F0 E6,F0

410A RRC 0F

410B RRC 0F

410C RRC 0F

410D RRC 0F

410E MOV D, A 57

410F MVI E, 0A 1E,0A

4111 XRA A AF

4112 MULT ADD E 83

4113 DCR D 15

4114 JNZ MULT C2,12,41

4117 ADD B 80

4118 STA 5101H 32,01,51

Page 55: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 55

411B HLT 76

ALGORITHM FOR BINARY TO BCD CONVERSION:

1. Initialize memory pointer to store BCD numbers.

2. Move data to accumulator.

3. Mark the most significant nibble.

4. Store it in B register.

5. Move the divider to C register.

6. Call division sub routine.

7. Store the result in the memory location mentioned.

8. Move the divider to C register.

9. Store the result.

10. End the program.

ALGORITHM FOR DIVISION SUBROUTINE:

1. Move ff to B register.

2. Count number of 100’s, 10’s and 1’s.

3. Subtract this from the content of C register.

4. If carry=1, then extract the remainder.

Page 56: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 56

FLOW CHART FOR BINARY TO BCD CONVERSION:

Page 57: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 57

Page 58: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 58

PROGRAM FOR BINARY TO BCD CONVERSION:

MEMORY

LOCATION LABEL MNEMONICS OPCODE COMMENTS

4200 START MVI E, 00H 1E,00

4202 MOV D, E 53

4203 LDA 4300H 3A,00,43

4206 HUND CPI 64H FE,64

4208 JC TEN DA,11,42

420B SUI 64H D6,64

420D INR E 1C

420E JMP HUND C3,06,42

4211 TEN CPI 0AH FE,0A

4213 JC UNIT DA,1C,42

4216 SUI 0A D6,0A

4217

4218 INR D 14

4219 JMP TEN C3,11,42

421C UNIT MOV C,A 4F

Page 59: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 59

421D MOV A, D 7A

421E RLC 07

MEMORY

LOCATION LABEL MNEMONICS OPCODE COMMENTS

421F RLC 07

4220 RLC 07

4221 RLC 07

4222 ADD C 81

4223 STA 4301H 32,01,43

4226 MOV A, E 7B

4227 STA 4302H 32

422A HLT 76

Page 60: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 60

FLOW CHART FOR DIVISION SUBROUTINE:

Page 61: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 61

DATA CHECK MAP FOR BCD TO BINARY CONVERSION:

MEMORY

LOCATION DATA 1 DATA 2

INPUT 5100H

OUTPUT 5101H

DATA CHECK MAP FOR BINARY TO BCD CONVERSION:

MEMORY

LOCATION DATA 1 DATA 2

INPUT 4300H

Page 62: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 62

OUTPUT 4301H

4302H

RESULT:

Thus the conversion from BCD to Binary and Binary to BCD were obtained.

ADC INTERFACING

AIM:

To interface DAC with 8085 and get the digital output.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Apply Control word for port A as input, Port B and Port C as Output

2. Out it in control register.

3. Make write pin high.

4. Port C is enabled for output.

5. Conversion is obtained using subroutine.

Page 63: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 63

PROGRAM:

ADDRESS LABEL MNEMONICS OPCOCDE COMMENTS

8500

8502

8505

8507

MVI A, 90 H

STA 40F3

MVI A, FFH

STA 40F2

3E, 90

32,F3,40

3E, FF

32,F2,40

Control word for A as input, B and C

aS Output

Out it in control reg

Make write pin high

Port C is enabled for output

Page 64: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 64

850A

850C

850F

8511

8514

8517

851A

851B

851D

51F

8520

8521

8522

8523

8524

8525

8528

8529

852C

MVI A, 00H

STA 40F2

MVI A, FFH

STA 40F2

CALL 851B

LDA 40F0

RST 1

MOV B,OF

MVI A,FF

NOP

NOP

NOP

NOP

NOP

DCR A

JNZ 851F

DCR A

JNZ 851D

RET

3E, 00

32,F2,40

3E, FF

32,F2,40

CD,86,00

3A,F0,40

CF

06,0F

3E, FF

00

00

00

00

00

3D

C2,1F,85

3D

C2,1F,85

C9

Start of conversion

Delay routine

End of conversion port A as input

Break point

Delay count

in

out

Return to main program

FLOWCHART:

Control word for port A as input, Port B

and Port C as Output

Out it in control register.

Start

Page 65: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 65

Page 66: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 66

Page 67: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 67

RESULT:

Thus the analog to digital conversion is obtained using 8085 microprocessor.

Page 68: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 68

IV. INTERFACING DAC WITH 8085 PROCESSOR

AIM:

To interface DAC with 8085 to demonstrate the generation of square, saw tooth and

Triangular wave.

APPARATUS REQUIRED:

8085Trainer Kit

DAC Interface Board

THEORY:

DAC 0800 is an 8–bit DAC and the output voltage variation is between –5V and

5V.The output voltage varies in steps of 10/256=0.04(appx.).The digital data input and

The corresponding output voltages are presented in the Table below.

Input Data in HEX Output Voltage

00 5.00

01 4.96

02 ..

7F

FD

FE 4.96

Page 69: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 69

FF 5.00

Referring toTable1, with 00 H as input to DAC, the analog output is –5 V.Similarly,

With FF H input, the output is +5V.Outputting digital data 00 and FF at regular intervals,

to DAC, results in different waveforms namely square, triangular, etc, the port address of

DAC is 08H.

ALGORITHM:

(a) Square Wave Generation

1. Load the initial value (00) to Accumulator and move it to DAC

2. Call the delay program

3. Load the final value (FF)to accumulator and move it to DAC

4. Call the delay program.

5. Repeat Steps 2 to 5

(b) Saw tooth Wave Generation

1.Load the initial value(00) to Accumulator

2.Move the accumulator content to DAC

3.Increment the accumulator content by 1.

4.Repeat Steps 3 and 4.

(c) Triangular Wave Generation

1. Load the initial value (00) to Accumulator

2. Move the accumulator content to DAC

3. Increment the accumulator content by1.

4. If accumulator content is zero proceed to next step. Else go to step3.

Page 70: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 70

5. Load value (FF) to Accumulator

6. Move the accumulator content to DAC

7. Decrement the accumulator content by1.

8. If accumulator content is zero go to step2. Else go to step7.

PROGRAM:

(a) Square Wave Generation

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

Page 71: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 71

8000

8002

8004

8007

8009

800B

800E

8011

8013

8015

8016

8019

801A

801D

START

DELAY

L1

L2

MVI A, 00

OUT Port address of DAC

CALL DELAY

MVI A, FF

OUT Port address of DAC

CALL DELAY

JMP START

MVI B, 05

MVI C, FF

DCR C

JNZ L2

DCR B

JNZ L1

RET

3E,00

D3,01

CD,0E,80

3E,FF

D3,02

CD,0E,80

C3,00,80

3E,05

0E,FF

0D

C2,13,80

05

C2,11,80

C9

Load the initial value (00) to Accumulator and move it to DAC

Call the delay program

Load the final value (FF)to

accumulator and move it to DAC

Call the delay program

Page 72: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 72

(B) Saw tooth Wave Generation

ADDRESS

LABEL MNEMONICS OPCODE COMMENTS

8020

8022

8023

8025

8026

8029

802B

802C

802E

802F

8032

START

L1

L2

MVI L, 00

MOV A, L

OUT Port address of DAC

INR L

JNZ L1

MVI L, FF

MOV A, L

OUT Port address of DAC

DCR L

JNZ L2

JMP START

2E,00

7D

D3,01

2C

C2,22,80

2E,FF

7D

D3,02

2D

C2,2B,80

C3,20,80

Load the initial value(00) to Accumulator

Move the accumulator

content to DAC

Page 73: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 73

(c) Triangular Wave Generation

ADDRESS LABEL MNEMONICS OPCODE

COMMENTS

8040

8042

8044

8045

8048

START

L1

MVI A, 00

OUT Port address of

DAC

INR A

JNZ L1

JMP START

3E,00

D3,01

3C

C2,42,80

C3,40,80

Load the initial value (00) to

Accumulator

Page 74: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 74

FLOW CHART FOR SQUARE WAVE FORM

Page 75: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 75

Page 76: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 76

FLOW CHART FOR TRIANGULAR WAVE FORM

Page 77: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 77

Page 78: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 78

FLOW CHART FOR SAW TOOTH WAVE FORM :

Page 79: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 79

Page 80: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 80

RESULT:

Thus the square, triangular and saw tooth waveform were generated by interfacing DAC with

8085 trainer kit.

Page 81: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 81

V. TRAFFIC LIGHT CONTROL INTERFACING

AIM:

Page 82: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 82

To control traffic light using 8085 microprocessor.

APPARATUS REQUIRED:

8085 Microprocessor kit with traffic light interfacing.

ALGORITHM:

1. Initialize 8255, port A and port B in output mode

2. Send data on PA to glow R1 and R2.

3. Send data on PB to glow G3 and G4.

4. Load multiplier count (40) for delay.

5. Call delay subroutine.

6. Send data on PA to glow Y1 and Y2.

7. Send data on PB to glow Y3 and Y4.

8. Load multiplier count (10) for delay.

9. Call delay subroutine.

10. Send data on PA to glow G1 and G2.

11. Send data on PB to glow R3 and R4.

12. Load multiplier count (40) for delay.

13. Call delay subroutine.

14. Send data on PA to glow Y1 and Y2.

15. Send data on PA to glow Y3 and Y4.

16. Load multiplier count (10) for delay.

17. Call delay subroutine

Page 83: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 83

FLOWCHART:

Initialize 8255, port A and port B

Send data on PA to glow R1 and R2.

Send data on PB to glow G3 and G4.

Call delay subroutine

Call delay subroutine

Send data on PA to glow Y1 and Y2.

Send data on PB to glow Y3 and Y4.

Send data on PA to glow G1 and G2.

Send data on PB to glow R3 and R4.

Call delay subroutine

Send data on PA to glow Y1 and Y2.

Send data on PA to glow Y3 and Y4.

Call delay subroutine

End

Start

Page 84: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 84

PROGRAM:

Source program:

ADDRESS LABEL

MNEMONICS OPCODE COMMENTS

8000

8002

8004

8006

8008

800A

800C

800E

8011

8013

8015

8017

8019

801C

801E

8020

8022

8024

START

MVI A, 80 H

OUT 83H(CR)

MVI A,09H

OUT 80H(PA)

MVI A,24H

OUT 81H(PB)

MVI C,28H

CALL DELAY

MVI A, 12H

OUT (81H) PA

OUT (81H) PB

MVI C,OAH

CALL DELAY

MVI A,24H

OUT (80H) PA

MVI A, 09H

OUT (81H) PB

MVI C,28H

3E,80

D3,83

3E,09

D3,80

3E,24

D3,81

0E,28

CD,40,80

3E,12

D3,81

D3,81

0E,0A

CD,40,80

3E,24

D3,80

3E,09

D3,81

0E,28

Initialize 8255, port A and port B

in output mode

Send data on PA to glow R1 and

R2

Send data on PB to glow G3 and

G4

Load multiplier count (40) for

delay

Call delay subroutine

Send data on PA to glow Y1 and

Y2

Send data on PB to glow Y3 and

Y4

Load multiplier count (10) for

delay

Call delay subroutine

Send data on PA to glow G1 and

G2

Send data on PB to glow R3 and

R4

Load multiplier count (40) for

Page 85: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 85

8026

8029

802B

802D

802F

803B

803F

CALL DELAY

MVI A, 12H

OUT PA

OUT PB

MVI C,OAH

CALL DELAY

JMP START

CD,40,80

3E,12

D3,80

D3,81

0E,0A

CD,40,80

C3,04,80

delay

Call delay subroutine

Send data on PA to glow Y1 and

Y2

Send data on PA to glow Y3 and

Y4

Load multiplier count (10) for

delay

Call delay subroutine

Delay subroutine:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

8040

8043

8044

8045

8046

8049

804A

804D

DELAY

BACK

LXI D,COUNT

DCX D

MOV A,D

ORA E

JNZ BACK

DCR C

JNZ DELAY

RET

11,XXXX

1B

7A

B3

C2,43,80

0D

C2,40,80

C9

Load the count to give 0.5 sec

delay

Decrement counter

Check whether count is 0

If not zero, repeat

Check if multiplier zero,

otherwise repeat

Return to main program

Page 86: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 86

TRAFFIC LIGHT CONTROL:

Page 87: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 87

RESULT:

Thus traffic light control is obtained using 8085 microprocessor

Page 88: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 88

Page 89: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 89

VI. STEPPER MOTOR CONTROL

AIM:

To write a program to rotate stepper motor in clockwise direction to 90 degree.

APPARATUS REQUIRED:

(i) 8085 Microprocessor kit

(ii) Stepper motor interfacing

(iii) Power supply.

ALGORITHM:

1. Move the data 60 to accumulator.

2. Move data count 90 degree to E register.

3. Send the accumulator to the input.

4. Wait for some delay.

5. Decrement the count.

6. Stop execution.

Page 90: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 90

PROGRAM:

ADDRESS LABEL MNEMONICS OPCOCDE COMMENTS

8020

8022

8024

8026

8029

802A

802B

802E

8030

8032

8034

8035

8038

8039

803C

DELAY

MVIA, 66

MVIE,50

OUT CO

CALL DELAY

RLC

D CR E

JNZ 8024

HLT

MVI C, 03

MVI B,FF

DCR B

JNZ 8034

DCR C

JNZ 8032

RET

3E,66

1E,50

D3,C0

CD,30,80

07

1D

C2,24,80

76

0E,03

06,FF

05

C2,34,80

0D

C3,32,80

C9

Move initial data to

accumulator

Move number count

Set it port 1

Wait for delay

Repeat left to accumulator`

Repeat count to 0

Repeat until zero

Stop execution

Move other count

Decrement inner count

Decrement B register

Repeat until 0

Decrement other loop

Repeat until 0

Return

Page 91: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 91

STEPPER MOTOR:

Page 92: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 92

STEPPER MOTOR:

Start

Initialize ports

Set count for four stepping sequence

Output data for a sequence

Wait for one ms

Decrement the count

Is count =0?

Page 93: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 93

NO

YES

RESULT:

Thus the program to rotate stepper motor in clockwise direction of 90 degree.

Page 94: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 94

VII (a). USART ( 8251)

AIM:

To write ALP to interface the universal synchronous asynchronous receiver and transmitter using 8085

microprocessor.

APPARATUS REQUIRED:

(i) 8085 microprocessor

(ii) Power supply

(iii) 8251 interfacing card

Page 95: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 95

ALGORITHM:

1. Initialize the serial port controller.

2. Get data from serial port

3. Transmit the byte serial port

4. Receive the byte from serial port.

TRASMIITTING MESSAGE

Initialize memory pointer

Initialize character counter

Start

Page 96: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 96

NO YES

NO

YES

Initialize 8251

Read status

Is transmitter

ready?

Send character to

transmitter

Increment memory

pointer

Decrement counter

Is counter=0?

End

Page 97: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 97

RECEIVER 8251

NO

NO

Initialize 8251

Read status

Is receiver

ready?

Send character to

transmitter

Increment memory

pointer

Read and save the

character transmitter

Increment memory

pointer

Decrement counter

Is counter=0?

End

Initialize memory pointer

Initialize character counter

Start

Page 98: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 98

YES

Page 99: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 99

Page 100: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 100

PROGRAM:

Look back test of 8251:

ADDRESS LABEL MNEMONICS OPCOCDE COMMENTS

8000

8003

8005

8007

800A

800C

800D

8010

8013

8014

8017

8018

801A

801C

801D

8020

CALL 8331

IN 01

ANI, 07H

JZ

INZ 00

MOV B,A

CALL 8350

CALL 8346

CHP B

JNZ

PUSH PSW

MVI A, 90 H

OUT 01

POP PSW

CALL 835C

JHP

CD,31,83

DB,01

E6,07

CA,

Page 101: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 101

Initialize serial port controller:

ADDRESS LABEL MNEMONICS OPCOCDE COMMENTS

8331

8333

8335

8337

8339

833B

833D

833E

8341

8343

8345

Retrieve a byte

from serial byte

8346

8348

834A

834D

834F

Transmit a byte to

serial port

8350

8351

8353

MVI A, 00H

OUT 41

OUT 41

OUT 41

MVI A, 40H

OUT 41

MVI A, 4FH

OUT 41

MVI A, 31H

OUT 41

RET

IN 41

ANI 02

JZ

IN 40

RET

PUSH PSW

IN 41

ANI 01

3E,00

D3,41

D3,41

D3,41

3E,40

D3,41

3E,4F

D3,41

3E,31

D3,41

C9

DB 41

E6,02

CA

DB,40

C9

F5

DB 41

E6,01

Move immediate data to

Acc.

Display

Display

Display

Move immediate data to

Acc.

Display

Move immediate data to

Acc.

Display

Move immediate data to

Acc.

Display

Return

INPUT

And immediate data of 02

Jump on 0

input

return

Page 102: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 102

8355

8358

8359

835B

JZ

POP PSW

OUT 40

RET

CA

F1

D3,40

C9

RESULT:

Thus the transmission and reception byte is achieved serially by interfacing 8085 with USART.

Page 103: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 103

VII (b) INTERFACING 8085 WITH 8279

AIM:

To write the program to show the LED segment in 8279 by interfacing 8085 with 8279.

APPARATUS REQUIRED:

(i) 8085 microprocessor

(ii) Power supply

(iii) Keyboard

(iv) 8279 interfacing card.

ALGORITHM:

1. Start the program.

2. Get the Hex code at the memory location 809, 800B,8011,8015

3. State results interfacing card 0123.

4. Stop the execution

Page 104: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 104

PROGRAM:

ADDRESS LABEL MNEMONICS OPCOCDE COMMENTS

Page 105: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 105

8000

8002

8004

8006

8008

800A

800C

800E

8010

8012

8014

8016

8018

801B

DELAY

MVIA, 00

OUT C2

MVIA, 90

OUT C2

MVIA, 3F

OUT C0

MVIA, 06

OUT C0

MVIA, 5B

OUT C0

MVIA, 4F

OUT C0

JMP 8018

HLT

3E,00

D3,C2

3E,90

D3,C2

3E,3F

D3,C0

3E,06

D3,C0

3E,5B

D3,C0

3E,4F

D3,C0

C3,18,80

76

Initialize accumulator

output from accumulator

move immediate data to

accumulator

output data from

accumulator

move immediate data to

accumulator

output data from

accumulator

move immediate data to

accumulator

output data from

accumulator

move immediate data to

accumulator

output data from

accumulator

move immediate data to

accumulator

output data from

accumulator

Jump to specify address

End of program

Page 106: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 106

FLOWCHART:

NO

yes

Decrement the count

Is count =0?

Start

Initialize keyboard /display

of 8279

Initialize prescaler count

Initialize 8279 in display RAM writ mode

Get 7 segment code

Write 7 segment code in display RAM

Start

Page 107: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 107

Page 108: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 108

RESULT:

Thus the LED segment display in 8279 by interfacing with 8085 was performed and verified.

Page 109: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 109

VII. (C). TIMER USING 8254

AIM:

To write a program for interfacing the 8253 with 8085 microprocessor.

APPARATUS REQUIRED:

(i) 8085 microprocessor

(ii) Power supply

(iii) 8254 interfacing card

ALGORITHM:

1. Move the content of word to Accumulator.

2. Move data to accumulator.

3. Move maximum content in acc to display in it output.

4. Move maximum count in operation

5. Stop execution.

Page 110: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 110

FLOW CHART:

Initialize internal counters with 0

Initialize hours, minutes and seconds

with 0

End

Initialize counter 0 of 8254 in square

wave mode

Load desired count in count register of

counter 0

Start

Page 111: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 111

PROGRAM:

ADDRESS LABEL MNEMONICS OPCOCDE COMMENTS

8000

8002

8004

8006

8008

800A

800C

MVI A, 30 H

OUT 43

MVI A, FFH

OUT 40

MVI A, FFH

OUT 40

HLT

3E, 30

D3,43

3E,FF

D3,40

3E,FF

D3,40

76

Move immediate data to

Acc.

Send the data from acc to

port

Move immediate data to

Acc.

Send the data from acc to

port

Move immediate data to

Acc.

Send the data from acc to

port

End the program

Page 112: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 112

Page 113: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 113

Page 114: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 114

RESULT:

Thus the program for interfacing 8354 with 8085 microprocessor was performed.

Page 115: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 115

VIII (a)16 BIT DATA ADDITION

AIM:

To add two 16-bit numbers stored at consecutive memory locations.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Initialize memory pointer to data location.

2. Get the first number from memory and store in Register pair.

3. Get the second number in memory and add it to the Register pair.

4. Store the sum & carry in separate memory locations.

Page 116: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 116

FLOW CHART:

NO

YES

START

[DE] [HL]

[L] [8052H]

[H] [8053H]

[A] 00H

[HL] [HL]+[DE]

[L] [8050 H]

[H] [8051 H]

Is there a

Carry?

STOP

[8054] [ L]

[8055] [H]

[A] [A]+1

[8056] [A]

Page 117: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 117

PROGRAM:

ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT

8000 2A START LHLD 8050H Load the augend in DE

pair through HL pair. 8001 50

8002 80

8003 EB XCHG

8004 2A LHLD 8052H Load the addend in HL

pair. 8005 52

8006 80

8007 3E MVI A, 00H Initialize reg. A for carry

8008 00

8009 19 DAD D Add the contents of HL

Pair with that of DE pair.

800A D2 JNC LOOP If there is no carry, go to

the instruction labeled

LOOP. 800B 0E

800C 80

800D 1C INR A Otherwise increment reg.

A

800E 22 LOOP SHLD 8054H Store the content of HL

Pair in 8054H(LSB of

sum) 800F 54

8010 80

8011 32 STA 8056H Store the carry in 8056H

through Acc. 8012 56

Page 118: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 118

8013 80 (MSB of sum).

8014 76 HLT Stop the program.

OBSERVATION:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

8050H 8054H

8051H 8055H

8052H 8056H

8053H

RESULT:

Thus an ALP program for 16-bit addition was written and executed in 8085 µp using special instructions.

Page 119: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 119

VIII.(b). 16 BIT DATA SUBTRACTION

AIM:

To subtract two 16-bit numbers stored at consecutive memory locations.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Initialize memory pointer to data location.

2. Get the subtrahend from memory and transfer it to register pair.

3. Get the minuend from memory and store it in another register pair.

4. Subtract subtrahend from minuend.

5. Store the difference and borrow in different memory locations.

Page 120: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 120

FLOW CHART:

START

[DE] [HL]

[L] [8052H]

[H] [8053H]

[HL] [HL]-[DE]

[L] [8050 H]

[H] [8051 H]

Page 121: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 121

YES

NO

PROGRAM:

ADDRESS OPCODE LABEL MNEMO

NICS

OPER

AND

COMMENTS

8000 0E,00 START MVI C, 00 Initialize C reg.

8002 2A,50,80 LHLD 8050H Load the subtrahend in DE reg.

Pair through HL reg. pair. 8005 EB XCHG

8006 2A,52,80 LHLD 8052H Load the minuend in HL reg.

Pair.

8009 7D MOV A, L Move the content of reg. L to

Acc.

Is there a

borrow?

STOP

[8054] [ L]

[8055] [H]

[C] [C]+1

[8056] [C]

Page 122: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 122

800A 93 SUB E Subtract the content of reg. E

from that of acc.

800B 6F MOV L, A Move the content of Acc. to

reg. L

800C 7C MOV A, H Move the content of reg. H to

Acc.

800D 9A SBB D Subtract content of reg. D with

that of Acc.

800E 67 MOV H, A Transfer content of acc. to reg.

H

800F 22,54,80 SHLD 8054H Store the content of HL pair in

memory location 8504H.

8012 D2,16,80 JNC NEXT If there is borrow, go to the

instruction labeled NEXT.

8015 0C INR C Increment reg. C

8016 79 NEXT MOV A, C Transfer the content of reg. C to

Acc.

8017 32,56,80 STA 8056H Store the content of acc. to the

memory location 8506H

801A 76 HLT Stop the program execution.

OBSERVATION:

INPUT OUTPUT

Page 123: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 123

ADDRESS DATA ADDRESS DATA

8050H 8054H

8051H 8055H

8052H 8056H

8053H

RESULT:

Thus an ALP program for subtracting two 16-bit numbers was written and executed.

VIII .(c).16 BIT MULTIPLICATION

AIM:

Page 124: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 124

To multiply two 16 bit numbers and store the result in memory.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Get the multiplier and multiplicand.

2. Initialize a register to store partial product.

3. Add multiplicand, multiplier times.

4. Store the result in consecutive memory locations.

Page 125: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 125

FLOWCHART:

NO

YES

NO

YES

START

L [8050]

H [8051]

L [8052]

H [8053]

SP HL

DE HL

HL 0000

BC 0000

HL HL+SP

Is Carry flag

set?

BC BC+1

DE DE+1

Is Zero flag

set?

A

Page 126: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 126

A

[8054] L

[8055] H

[8056] C

[8057] B

STOP

Page 127: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 127

PROGRAM:

Page 128: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 128

ADDRE

SS

OPCODE LABEL MNEMO

NICS

OPERAND COMMENTS

8000 2A START LHLD 8050 Load the first No. in stack pointer

through HL reg. pair 8001 50

8002 80

8003 F9 SPHL

8004 2A LHLD 8052 Load the second No. in HL reg. pair

& Exchange with DE reg. pair. 8005 52

8006 80

8007 EB XCHG

8008 21 LXI H, 0000H

Clear HL & DE reg. pairs. 8009 00

800A 00

800B 01 LXI B, 0000H

800C 00

800D 00

800E 39 LOOP DAD SP Add SP with HL pair.

800F D2 JNC NEXT If there is no carry, go to the

instruction labeled NEXT 8010 13

8011 80

8012 03 INX B Increment BC reg. pair

8013 1B NEXT DCX D Decrement DE reg. pair.

8014 7B MOV A,E Move the content of reg. E to Acc.

8015 B2 ORA D OR Acc. with D reg.

8016 C2 JNZ LOOP If there is no zero, go to instruction

labeled LOOP 8017 0E

8018 80

8019 22 SHLD 8054 Store the content of HL pair in

memory locations 8054 & 8055. 801A 54

801B 80

801C 79 MOV A, C Move the content of reg. C to Acc.

801D 32 STA 8056 Store the content of Acc. in memory

location 8056. 801E 56

801F 80

8020 78 MOV A, B Move the content of reg. B to Acc.

8021 32 STA 8057 Store the content of Acc. in memory

location 8056. 8022 57

8023 80

8024 76 HLT Stop program execution

Page 129: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 129

OBSERVATION:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

8050 8054

8051 8055

8052 8056

8053 8057

RESULT:

Thus the 16-bit multiplication was done in 8085µp using repeated addition method.

Page 130: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 130

VIII (d). 16- BIT DIVISION

AIM:

To divide two 16-bit numbers and store the result in memory using 8085 mnemonics.

APPARATUS REQUIRED:

8085-Microprocessor kit -1

ALGORITHM:

1. Get the dividend and divisor.

2. Initialize the register for quotient.

3. Repeatedly subtract divisor from dividend till dividend becomes less than divisor.

4. Count the number of subtraction which equals the quotient.

5. Store the result in memory.

Page 131: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 131

FLOWCHART:

NO

YES

START

L [8051]

H [8052]

HL DE

L [8050]

H [8051]

BC 0000H

A L; A A- E

L A

A H

A A- H- Borrow

BC BC+ 1

Is Carry

flag set ?

A

Page 132: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 132

A

BC BC- 1

HL HL+DE

L [8054]

H [8055]

A C

[8056] A

A B

[8057] A

STOP

Page 133: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 133

PROGRAM:

ADDRESS OPCODE LABEL MNEM

ONICS

OPERA

ND

COMMENTS

8000 2A,52,80 START LHLD 8052 Load the first No. in stack pointer through

HL reg. pair 8003 EB XCHG

8004 2A,50,80 LHLD 8050 Load the second No. in HL reg. pair

& Exchange with DE reg. pair.

8007 01,00,00 LXI B, 0000H

Clear BC reg. pair.

800A 7F LOOP MOV A, L Move the content of reg. L to Acc.

800B 93 SUB E Subtract reg. E from that of Acc.

800C 6F MOV L, A Move the content of Acc to L.

800D 7C MOV A, H Move the content of reg. H Acc.

800E 9A SBB D Subtract reg. D from that of Acc.

800F 67 MOV H, A Move the content of Acc to H.

8010 03 INX B Increment reg. Pair BC

8011 D2,0A,80 JNC LOOP If there is no carry, go to the location

labeled LOOP.

8014 0B DCX B Decrement BC reg. pair.

8015 19 DAD D Add content of HL and DE reg. pairs.

8016 22,54,80 SHLD 8054 Store the content of HL pair in 8054 &

8055.

8019 79 MOV A, C Move the content of reg. C to Acc.

Page 134: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 134

801A 32,56,80 STA 8056 Store the content of Acc. in memory 8056

801D 78 MOV A, B Move the content of reg. B to Acc.

801E 32,57,80 STA 8057 Store the content of Acc. in memory 8057.

8021 76 HLT Stop the program execution.

OBSERVATION:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

8050 8054

8051 8055

8052 8056

8053 8057

RESULT:

Thus the 16-bit Division was done in 8085µp using repeated subtraction method.

Page 135: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 135

8051 MICROCONTROLLER

PROGRAMS

Page 136: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 136

IX. (A) ADDITION OF TWO 8 – BIT NUMBERS

AIM:

To perform addition of two 8–bit numbers using 8051 instruction set.

ALGORITHM:

1. Clear C–register for Carry

2. Get the data immediately.

3. Add the two data

4. Store the result in memory pointed by DPTR

Page 137: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 137

PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

HERE:

ORG 4100

CLR C

MOV A,#data1

ADD A,#data2

MOV DPTR,#4500

MOVX ,@DPTR,A

SJMP HERE

FLOWCHART:

Page 138: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 138

OBSERVATION:

Page 139: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 139

Input: 66

23

Output: 89(4500)

RESULT:

Thus the program to perform addition of two 8–bitnumbers using 8051 instruction set

was executed.

Page 140: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 140

IX. (B) SUBTRACTION OF TWO 8 – BIT NUMBERS

AIM:

To perform Subtraction of two 8–bit numbers using 8051 instruction set.

ALGORITHM:

1. Clear C–register for Carry

2. Get the data immediately.

3. Subtract the two data

4. Store the result in memory pointed by DPTR

` PROGRAM:

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

HERE

ORG 4100

CLR C

MOV A, #data1

SUBB A, #data2

MOV DPTR, #4500

MOVX @DPTR, A

SJMP HERE

Page 141: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 141

FLOWCHART:

Page 142: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 142

OBSERVATION:

Input: 66

23

Output: 43(4500)

RESULT:

Thus the program to perform subtraction of two 8–bit numbers using 8051 instruction

Set was executed.

Page 143: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 143

IX (C)MULTIPLICATION OF TWO 8 – BIT NUMBERS

AIM:

To perform multiplication of two 8–bit numbers using 8051 instruction set.

ALGORITHM:

1. Get the data in A–reg.

2. Get the value to be multiplied in B–reg.

3. Multiply the two data

4. The higher order of the result is in B–reg.

5. The lower order of the result is in A–reg.

6. Store the results.

PROGRAM:

Page 144: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 144

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

HERE

ORG 4100

CLR C

MOV A,#data1

MOV B,#data2

MUL AB

MOV DPTR,#4500

MOVX @DPTR,A

INC DPTR

MOV @DPTR,A

MOVX A,B

SJMP HERE

OBSERVATION:

Input: 80

80

Output: 00(4500)

19(4501)

Page 145: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 145

RESULT:

Thus the program to perform multiplication of two 8–bit numbers using 8051

Instruction set was executed.

IX (D) DIVISION OF TWO 8 – BIT NUMBERS

AIM:

To perform division of two 8–bit numbers using 8051 instruction set.

ALGORITHM:

1. Get the data in A–reg.

2. Get the value to be divided in B–reg.

3. Divide the two data

Page 146: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 146

4. The quotient is in A–reg.

5. The remainder is in B–reg.

6. Store the results.

PROGRAM:

ADDRESS LABEL MNENONICS OPCODE COMMENTS

HERE

ORG4100

CLR C

MOV A,#data1

MOV B,#data2

DIV AB

MOV DPTR,#4500

MOVX @DPTR,A

INC DPTR

MOV A,B

MOV@DPTR,A

SJMP HERE

OBSERVATION:

Input: 05

Page 147: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 147

03

Output: 01(4500)

02(4501)

RESULT:

Thus the program to perform division of two 8–bit numbers using 8051

Instruction set was executed.

X. KEY BOARD/DISPLAY INTERFACING

Page 148: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 148

AIM:

To write a program for key board/display interfacing with 8051 microcontroller.

APPARATUS REQUIRED:

(i) 8051 microcontroller

(ii) Power supply

ALGORITHM:

1. Initialize P1.0, P1.1, P1.2, P1.3 as inputs i.e. write ‘1’to these pins.

2. Check if all the keys are released by writing ‘0’ to P1.4, P1.7 and check if all return lines are in state,1,. If No

then wait. Call debounce.

3. Wait for key closure. Ground all scan lines by writing ,0, and then check if at least one of return lines shows ‘0’ level. Key

pressed? No step 4. Yes step 5.

4. Call debounce.

5. Is key really pressed? (Ground all sacn lines by writing ,0, and then check if at least one of return lines shows ‘0’ level) No

step 4.Yes step 7.

6. Find key code and display the key pressed on 7 segment display. ( By Grounding one scan line at a time and checking for any

line to go to ‘0’ level).

7. Go to step 1.

Page 149: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 149

PROGRAM:

ADDRESS LABEL MNEMONICS OPCO

CDE

COMMENTS

BEG

AGA

GO

GOL

AGA 3

MOV P1, #0FH

MOV DPTR, #4000H

MOV A, #P1

ANL A, #0FH

CJNE A, #0FH, AGA

LCALL DELAY

MOV A, #P1

ANL A, #0FH

CJNE A, #0FH, GO

LJMP AGAL

LCALL DELAY

MOV A, #P1

ANL A, #0FH

CJNE A, #0FH, GOL

LJMP AGAL

MOV R1, #01H

MOV R0, #0EFH

MOV R3, #04H

MOV P1,R0

MOV A,P1

JNB .ACC.0, DISPLAY

INC DPTR

Configure lower 4 lines of

port1 as input

Initialize dptr with lookup table

address

Check for key released

Call delay routine for key

debounce

Check for key presssed

Call delay routine for key

debounce

Is key pressed

Initialize counter 1

Store word for column

selection

Initialize column counter

Select only l column

Get the status of return lines

Check bit 0 and if it is 1 junp to

display

Page 150: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 150

JNB .ACC.1, DISPLAY

INC DPTR

JNB .ACC.2, DISPLAY

INC DPTR

JNB .ACC.3, DISPLAY

INC DPTR

MOV A,R0

MOV R1,A

MOV R0,A

DJNZ R3, AGA 3

LJMP BEG

END

Increment lookup-table pointer

Check bit 1 and if it is 1 junp to

display

Increment lookup-table pointer

Check bit 2 and if it is 1 junp to

display

Increment lookup-table pointer

Check bit 3 and if it is 1 junp to

display

Increment lookup-table pointer

Get the word for column

selection

Select next column

Store 4the word for column

selection

Check for last column

If any key is not pressed scan

again

Page 151: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 151

Page 152: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 152

KEY BOARD/DISPLAY INTERFACING

RESULT:

Thus the keyboard interfacing using 8051 was performed.

Page 153: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 153

XI. STEPPER MOTOR INTERFACING WITH 8051

AIM:

To interface a stepper motor with 8051 microcontroller and operate it.

APPARATUS REQUIRED:

1. 8051-microcontroller kit and Stepper motor

THEORY: A motor in which the rotor is able to assume only discrete stationary angular position is a stepper motor. The rotary

motion occurs in a step-wise manner from one equilibrium position to the next. Stepper Motors are used very wisely in position

control systems like printers, disk drives, process control machine tools, etc.

The basic two-phase stepper motor consists of two pairs of stator poles. Each of the four poles has its own winding. The

excitation of any one winding generates a North Pole. A South Pole gets induced at the diametrically opposite side. The rotor

magnetic system has two end faces. It is a permanent magnet with one face as South Pole and the other as North Pole.

The Stepper Motor windings A1, A2, B1, B2 are cyclically excited with a DC current to run the motor in clockwise

direction. By reversing the phase sequence as A1, B2, A2, B1, anticlockwise stepping can be obtained.

2-PHASE SWITCHING SCHEME:

In this scheme, any two adjacent stator windings are energized. The switching scheme is shown in the table given below.

This scheme produces more torque.

ANTICLOCKWISE CLOCKWISE

STEP A1 A2 B1 B2 DATA STEP A1 A2 B1 B2 DATA

1 1 0 0 1 9h 1 1 0 1 0 Ah

2 0 1 0 1 5h 2 0 1 1 0 6h

3 0 1 1 0 6h 3 0 1 0 1 5h

Page 154: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 154

4 1 0 1 0 Ah 4 1 0 0 1 9h

ADDRESS DECODING LOGIC:

The 74138 chip is used for generating the address decoding logic to generate the device select pulses, CS1

& CS2 for selecting the IC 74175.The 74175 latches the data bus to the stepper motor driving circuitry.

Stepper Motor requires logic signals of relatively high power. Therefore, the interface circuitry that

generates the driving pulses use silicon darlington pair transistors. The inputs for the interface circuit are TTL

pulses generated under software control using the Microcontroller Kit. The TTL levels of pulse sequence from

the data bus is translated to high voltage output pulses using a buffer 7407 with open collector.

PROCEDURE:

Enter the above program starting from location 4100.and execute the same. The stepper motor rotates.

Varying the count at R4 and R5 can vary the speed. Entering the data in the look-up TABLE in the reverse order can

vary direction of rotation.

Page 155: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 155

STEPPER MOTOR

Page 156: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 156

FLOWCHART:

NO

YES

Start

Initialize ports

Set count for four stepping sequence

Output data for a sequence

Wait for one ms

Decrement the count

Is count =0?

Page 157: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 157

PROGRAM : ADDRE

SS OPCODES LABEL MNEMONICS

COMMENTS

ORG 4100h

4100

START: MOV DPTR, #TABLE Load the start address of

switching scheme data

TABLE into Data Pointer

(DPTR)

4103 MOV R0, #04 Load the count in R0

4105

LOOP: MOVX A, @DPTR Load the number in TABLE

into A

4106 PUSH DPH Push DPTR value to Stack

4108 PUSH DPL

410A

MOV DPTR, #0FFC0h Load the Motor port address

into DPTR

410D

MOVX @DPTR, A Send the value in A to

stepper Motor port address

410E MOV R4, #0FFh Delay loop to cause a

specific amount of time

delay before next data item

is sent to the Motor

4110 DELAY: MOV R5, #0FFh

4112

DELAY1

:

DJNZ R5, DELAY1

4114 DJNZ R4, DELAY

4116 POP DPL POP back DPTR value

from Stack 4118 POP DPH

411A

INC DPTR Increment DPTR to point to

next item in the table

411B

DJNZ R0, LOOP Decrement R0, if not zero

repeat the loop

411D

SJMP START Short jump to Start of the

program to make the motor

rotate continuously

Page 158: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 158

411F

TABLE: DB 09 05 06 0Ah Values as per two-phase

switching scheme

RESULT:

Thus a stepper motor was interfaced with 8051 and run in forward and reverse directions at various speeds.

Page 159: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 159

XI (A) INTERFACING DAC WITH 8051

AIM:

To interface DAC with 8051 parallel port to demonstrate the generation of square,

Saw tooth and triangular wave.

APPARATUS REQUIRED:

8051Trainer Kit

DAC Interface Board

THEORY:

DAC 0800 is an 8–bit DAC and the output voltage variation is between –5V and

5V.The output voltage varies in steps of 10/256=0.04(appx.).The digital data input and

The corresponding output voltages are presented in the Table below

.

Input Data in HEX Output Voltage

00 5.00

01 4.96

02 ..

7F

Page 160: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 160

FD

FE 4.96

FF 5.00

Referring to Table1,with 00 H as input to DAC, the analog output is –5 V. Similarly,

With FF H as input, the output is +5V. Outputting digital data 00 and FF at regular intervals,

to DAC , results in different waveforms namely square, triangular ,etc,.

ALGORITHM:

(a) Square Wave Generation

1. Move the port address of DAC to DPTR

2. Load the initial value(00) to Accumulator and move it to DAC

3. Call the delay program

4. Load the final value(FF) to accumulator and move it to DAC

5. Call the delay program.

6. Repeat Steps 2 to 5

(b) Saw tooth Wave Generation

1. Move the port address of DAC to DPTR

2. Load the initial value (00) to Accumulator

3. Move the accumulator content to DAC

4. Increment the accumulator content by 1.

5. Repeat Steps 3 and 4.

(c) Triangular Wave Generation

Page 161: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 161

1. Move the port address of DAC to DPTR

2. Load the initial value (00) to Accumulator

3. Move the accumulator content to DAC

4. Increment the accumulator content by 1.

5. If accumulator content is zero proceed to next step. Else go to step3.

6. Load value(FF) to Accumulator

7. Move the accumulator content to DAC

8. Decrement the accumulator content by 1.

9. If accumulator content is zero go to step 2. Else go to step 7.

PROGRAM:

a) Square Wave Generation

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

Page 162: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 162

START

DELAY:

LOOP:

HERE

ORG 4100

MOV

DPTR,PORTADDRESSOFDAC

MOV A,#00

MOVX @DPTR,A

LCALL DELAY

MOV A,#FF

MOVX @DPTR,A

LCALL DELAY

LJUMP START

MOV R1,#05

MOV R2,#FF

DJNZ R2,HERE

DJNZ R1,LOOP

RET

SJMP START

(b) Saw tooth Wave Generation

Page 163: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 163

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

LOOP

ORG 4100

MOV DPTR, PORT ADDRESS

OF DAC

MOV A,#00

MOVX @DPTR ,A

INC A

SJMP LOOP

(c) Triangular Wave Generation

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

START

LOOP1

LOOP2:

ORG 4100

MOV DPTR, PORT

ADDRESS OF DAC

MOV A,#00

MOVX @DPTR ,A

INC A

JNZ LOOP1

MOV A,#FF

MOVX @DPTR,A

DEC A

JNZ LOOP2

LJMP START

Page 164: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 164

FLOWCHART:

Page 165: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 165

Page 166: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 166

DAC INTERFACING

Page 167: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 167

RESULT:

Thus the square, triangular and saw tooth waveform were generated by interfacing

DAC with 8051 trainer kit.

Page 168: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 168

I(B) TRAFFIC LIGHT CONTROL INTERFACING

AIM:

To control traffic light using 8051 microcontroller.

APPARATUS REQUIRED:

8051 microcontroller kit with traffic light interfacing .

ALGORITHM:

1. Initialize R0 to make P1.0 high.

2. Initialize R1 to make P1.1 high.

3. Initialize R2 to make P1.2 high.

4. Make P1.0 high. Wait for 20 seconds

5. Make P1.1 high. Wait for 5 seconds

6. Make P1.2 high. Wait for 20 seconds

7. Make P1.1 high. Wait for 5 seconds.

8. Jump to start.

.

Page 169: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 169

PROGRAM:

ADDRESS LABEL MNEMONICS OPCOCDE COMMENTS

MOV R0, #01H

MOV R1, #02H

MOV R2, #04H

MOV P1, R0

LCALL DELAY1

MOV P1, R1

LCALL DELAY2

MOV P1, R2

LCALL DELAY1

MOV P1, R1

LCALL DELAY2

LJMP START

Initialize R0 to make P1.0 high.

Initialize R1 to make P1.1

high.

Initialize R2 to make P1.2

high.

Make P1.0 high

Wait for 20 seconds

Make P1.1 high

Wait for 5 seconds

Make P1.2 high

Wait for 20 seconds

Make P1.1 high

Wait for 5 seconds.

Jump to start.

Page 170: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 170

TRAFFIC LIGHT CONTROL:

Page 171: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 171

RESULT:

Thus traffic light control using 8051 microcontroller was performed

Page 172: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 172

XI (C) 8051 SERIAL PORT COMMUNICATION

AIM:

To write assembly language program to receive bytes serially with baud rate 9600, 8-bit data and 1 stop

bit. Simultaneously sent received bytes to port2.

APPARATUS REQUIRED:

(i) 8051 microcontroller

(ii) Power supply

ALGORITHM:

1. Load the TMOD register with the value 20H to use timer 1 in mode 2 to set the baud rate.

2. Load TH1 to set the desire baud rate for serial data transfer.

3. Load SCON register with the value 50 H to use serial mode 1, where an 8-bit data is framed with start

and stop bits.

4. Set TR1 to 1 to start timer 1.

5. Clear the RI with CLR RI instruction.

6. Check the RI flag bit with instruction JNB RI, XXXX to see if an entire character has been received

yet.

7. If RI is set, SBUF has the byte. Save this byte.

8. Go to step 5 to receive the next character.

Page 173: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 173

PROGRAM:

ADDRESS LABEL MNEMONICS OPCOCDE COMMENTS

HERE

MOV TMOD, #20H

MOV TH1, #FDH

MOV SCON, #50H

SETB TR1

JNB RI, HERE

MOV A, SBUF

MOV P2, A

CLR RI

SJMP HERE

Timer 1, mode 2

9600 baud rate

8-bit, 1-stop, REN enabled

Start timer 1

Wait for character receive

Completely

Save the received character

Sent character to port 2

Get ready to receive next byte

Go to receive next character

Page 174: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 174

XI (C) 8051 SERIAL PORT COMMUNICATION

Page 175: LAB MANUAL EE2356 MICROPROCESSOR AND MICRO …

www.Vidyarthiplus.com

www.Vidyarthiplus,com Page 175

RESULT:

Thus the data was received in port 2 using 8051 serial port communication.