Sunteți pe pagina 1din 146

Experiment No: …………….

Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 1

1.PROGRAM FOR ALU OPERATIONS (8085)


A) 8-BIT DATA ADDITION-8085
Aim:
To add two 8 bit numbers stored at consecutive memory locations.
.

Equipment and Components Required:

Power supply, 8085 kit

Algorithm:

 Initialize memory pointer to data location.

 Get the first number from memory in accumulator.

 Get the second number and subtract from the accumulator.

 If the result yields a borrow, the content of the acc. is complemented and 01H is added

to it (2’s complement). A register is cleared and the content of that reg. is incremented

in case there is a borrow. If there is no borrow the content of the acc. is directly taken

as the result.

 Store the answer at next memory location.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 2

Flow chart:
START

[C] 00H

[HL] 4500H

[A] [M]

[HL] [HL]+1

[A] [A]-[M]

If
Borrow?
N

Y
Complement [A]

Add 01H to [A]

[C] [C]+1

[HL] [HL]+1

[M] [A]

[HL] [HL]+1

[M] [C]

STOP

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 3

Program:

ADDRESS/LABEL MNEMONICS OPERAND OPCODE BYTES MACHINE CYCLES T-STATES EXECUTION TIME COMMENTS
4100 / START 0E
2 3.5 µs
MVI C, 00 2 7T Clear C reg.
4101 00
4102 21
00 3 5 µs
4103 LXI H, 4500 Initialize HL reg. to 4500
3 10T
4104 45

4105 MOV A, M 7E 1 1 7T 3.5 µs Transfer first data to accumulator

Increment HL reg. to point next


4106 INX H 23 1 6T
memory Location.
1 3 µs

4107 ADD M 86 1 2 7T 3.5 µs Add first number to acc. Content.

3.5 µs / 5 µs
4108 D2
2/ 3 7T / 10T
3 Jump to location if result does not
4109 JNC L1 0C (if condition is not true (if condition is
yield carry.
/ true) not true / true)
410A 41
410B INR C 0C 1 1 4T 2 µs
Increment C reg.

Increment HL reg. to point next


410C / L1 INX H 23 1 6T
memory Location.
1 3 µs
Transfer the result from acc. to
410D MOV M, A 77 1
2 7T
3.5 µs memory.
Increment HL reg. to point next
410E INX H 23 1 6T
memory Location.
1 3 µs
VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 4

410F MOV M, C 71 1 2 7T 3.5 µs


Move carry to memory

4110 HLT 76 1 2 5T 2.5 µs


Stop the program

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 5

Calculations :

Clock frequency F=2MHz


T-State =Clock Period (1/F) = 0.5µs
Execution time for Opcode Fetch: (4T)*0.5= 2 µs
Execution time for Memory Read: (3T)*0.5= 1.5 µs
Execution time for Instruction: (7T)*0.5= 3.5 µs

Total No. of T States:


If condition true:
If condition false:

Observation:

INPUT OUTPUT

4500 FF 4502 FE
4501 FF 4503 01

Conclusion:

Thus the 8 bit numbers stored at 4500 &4501 are added and the result stored at 4502 &
4503.

……………………………………………………………………………………………………………………………………

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 6

Questions:

1. What type of architecture used in 8085 microprocessor?

2. What is the function of accumulator?

3. What are the different types of flags in 8085 microprocessor?

4. What are the types of general purpose registers in 8085?

5. What is the length of stack pointer in 8085 microprocessor?

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 7

B) 8 BIT DATA SUBTRACTION-8085


Aim:
To subtract two 8 bit numbers stored at consecutive memory locations.

Equipment and Components Required:

Power supply, 8085 kit

Algorithm:

 Initialize memory pointer to data location.

 Get the first number from memory in accumulator.

 Get the second number and subtract from the accumulator.

 If the result yields a borrow, the content of the acc. is complemented and 01H is

added to it (2’s complement). A register is cleared and the content of that reg. is

incremented in case there is a borrow. If there is no borrow the content of the

acc. is directly taken as the result.

 Store the answer at next memory location.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 8

Flow Chart:

START

[C] 00H

[HL] 4500H

[A] [M]

[HL] [HL]+1

[A] [A]-[M]

Is there NO
a
YES

Complement [A]

Add 01H to [A]

[C] [C]+1

[HL] [HL]+1

[M] [A]

[HL] [HL]+1

[M] [C]

STOP

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 9

Program:
ADDRESS/LABEL MNEMONICS OPERAND OPCODE BYTES MACHINE CYCLES T-STATES EXECUTION TIME COMMENTS
4100/START MVI C, 00

4102 LXI H, 4500


4103
4104
4105 MOV A, M
4106 INX H
4107 SUB M
4108 JNC L1
4109
410A
410B INR C
410C CMA
410D ADI 01H
410E
410F/L1 INX H
4110 MOV M, A
4111 INX H
4112 MOV M, C
4113 HLT

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 10

Calculations:

Clock frequency F=2MHz

T-State =Clock Period (1/F) = 0.5µs

Execution time for Opcode Fetch: (4T)*0.5= 2 µs

Execution time for Memory Read: (3T)*0.5= 1.5 µs

Execution time for Instruction: (7T)*0.5= 3.5 µs

Total No. of T States:


If condition true:
If condition false:

Observation:

INPUT OUTPUT
4500 45 4502 4B
4501 90 4503 01

Conclusion:

Thus the 8 bit numbers stored at 4500 &4501 are subtracted and the result stored at
4502 & 4503.

……………………………………………………………………………………………………………………………………
…..

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 11

Questions:

1. What is the memory size of 8085 microprocessor?

2. How many bits is 8085 microprocessor?

3. What are the various interrupts in 8085 microprocessor? Which is the highest
priority interrupt?

4. Which type of cycle is used for fetch and execute instruction?

5. How many address lines are there in 8085 microprocessor?

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 12

C) 8 BIT DATA MULTIPLICATION-8085


Aim:
To multiply two 8 bit numbers stored at consecutive memory locations and store the
result in memory.

Equipment and Components Required:

Power supply, 8085 kit

Algorithm:

LOGIC: Multiplication can be done by repeated addition.

 Initialize memory pointer to data location.

 Move multiplicand to a register.

 Move the multiplier to another register.

 Clear the accumulator.

 Add multiplicand to accumulator

 Decrement multiplier

 Repeat step 5 till multiplier comes to zero.

 The result, which is in the accumulator, is stored in a memory location.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 13

Flow Chart:
START

[C] 00H

[HL] 4500H

[A] [M]

[HL] [HL]+1

[A] [A]-[M]

Is there NO
a
YES

Complement [A]

Add 01H to [A]

[C] [C]+1

[HL] [HL]+1

[M] [A]

[HL] [HL]+1

[M] [C]

STOP

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 14

Program:

ADDRESS/LABEL MNEMONICS OPERAND OPCODE BYTES MACHINE CYCLES T-STATES EXECUTION TIME COMMENTS
4100/START LXI H, 4500
4101
4102
4103 MOV B, M
4104 INX H
4105 MVI A, 00H
4106
4107 MVI C, 00H
4108
4109/L1 ADD M
410A JNC NEXT
410B
410C
410D INR C
410E DCR B
410F JNZ L1
4110
4111
4112 INX H
4113 MOV M, A
4114 INX H
4115 MOV M, C
4116 HLT

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 15

Calculations :

Clock frequency F=2MHz


T-State =Clock Period (1/F) = 0.5µs
Execution time for Opcode Fetch: (4T)*0.5= 2 µs
Execution time for Memory Read: (3T)*0.5= 1.5 µs
Execution time for Instruction: (7T)*0.5= 3.5 µs

Total No. of T States:


If condition true:
If condition false:

Observation:

INPUT OUTPUT
4500 05 4502 32
4501 0A 4503 00

Conclusion:

Thus the 8-bit multiplication was done in 8085 microprocessor using repeated
addition method.

……………………………………………………………………………………………………………………………………
….

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 16

Questions:

1. Why crystal is being preferred as a clock source?

2. Name High order / Low order register in 8085 microprocessor?

3. What is Tri-state logic?

4. What will happen if HLT instruction is executed in processor?

5. Which Stack is used in 8085?

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 17

D) 8 BIT DIVISION-8085
Aim:
To divide two 8-bit numbers and store the result in memory.

Equipment and Components Required:

Power supply, 8085 kit

Algorithm:

LOGIC:
Division is done using the method Repeated subtraction.

 Load Divisor and Dividend

 Subtract divisor from dividend

 Count the number of times of subtraction which equals the quotient

 Stop subtraction when the dividend is less than the divisor .The dividend now

becomes the remainder. Otherwise go to step 2.

 Stop the program execution.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 18

Flow Chart:
START

B  00

[HL] 4500

A M

[HL]  [HL]+1

M  A-M

[B]  [B] +1

NO
IS A<0
YES
A  A+ M

B  B-1

[HL] [HL]+1

[M] [A]

[HL] [HL]+1

[M] [B]

STOP

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 19

Program:

ADDRESS/LABEL MNEMONICS OPERAND OPCODE BYTES MACHINE CYCLES T-STATES EXECUTION TIME COMMENTS
4100 MVI B,00

4101

4102 LXI H,4500


4103
4104
4105 MOV A,M
4106 INX H
4107 SUB M
4108 INR B
4109
JNC LOOP
410A

410B

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 20

410C ADD M
410D DCR B
410E INX H
410F MOV M,A
4110 INX H
4111 MOV M,B
4112 HLT

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 21

Calculations:

Clock frequency F=2MHz


T-State =Clock Period (1/F) = 0.5µs
Execution time for Opcode Fetch: (4T)*0.5= 2 µs
Execution time for Memory Read: (3T)*0.5= 1.5 µs
Execution time for Instruction: (7T)*0.5= 3.5 µs

Total No. of T States:


If condition true:
If condition false:

Observation:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4500 32 4502 05
4501 0A 4503 00
4500 05 4502 02
4501 02 4503 01

Conclusion:

Thus an ALP was written for 8-bit division using repeated subtraction method and
executed using 8085

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 22

Questions:

1. Define microprocessor.

2. Define micro controller.

3. Compare microprocessor and micro controller.

4. List some application of microprocessor and micro controller.

5. Define machine language and assembly language.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 23

Lab Exercises:

1. Write an Arithmetic logic program for repeated subtraction in 650000 data1 = AB H,


data2 = 12 H using in direct addressing mode of8085.

2. Write an Arithmetic logic program to store the repeated addition in memory location
7000 of inputs AA & BB using indirect addressing mode of 8085.

3. Write an Arithmetic logic program to store the product in memory location 7000 of
inputs AB & BC using direct addressing mode of8085.

4. Write an Arithmetic logic program to store the debit value in memory location of the
inputs (2’s complement of data1=A3 H and data2 = 93 H ] Using 8085.

5. Write an Arithmetic logic program to store the debit value in memory location 6500
of the two immediate input data using 8085

6. Write an Arithmetic logic program to store the sum in memory location 4504 H &
carry in the subsequent memory location of the two immediate input data using 8085
and calculate the execution time total T states.

7. Write an Arithmetic logic program to store the sum in memory location 7503 H &
carry in the subsequent memory location of the two input data in 8085. Input 1 in
7401 and input 2 in 7408 using indirect addressing modes.

8. Write an Assembly language program to perform NOR operation on a 8 bit number


using 8085.

9. Write an Assembly language program to perform AND operation on 8 bit number


using 8085.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 24

2. REAL TIME CLOCK GENERATION (8085)

Aim:
To write the program to realize real time clock. Display second in data field, minutes and
hours in address field using 8085.

.
Equipment and Components Required:

Power supply, 8085 kit

Algorithm:

 Initialize the data for seconds in Acc.

 Initialize the data for minutes in L register.

 Initialize the data for hours in H register.

 Display the data in display field.

 Call proper delay of one second.

 Increment the second by 01 and compare it with the value 60 suitably if it is equal

increment the minute by 1 and compare it with the value 24 suitably, if not for all

the above increment the second value and repeat the steps 4-5

 Termination.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 25

Flow chart:

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 26

Program:

BYTES EXECUTION COMMENTS


ADDRESS/LABEL MNEMONICS OPERAND OPCODE MACHINE CYCLES T-STATES
TIME
4100
MVI B,03
4101
4102
4103 LXI H,DATA
4104
4105/ L2 MOV A,M
4106
4107 STA BUFFER
4108
4109
MVI C,0A
410A
410B
ANI FO
410C
410D RLC
410E RLC
410F RLC
4110 RLC
4111 MOV D,A
4112 SUB B
4113/ L1 ADD D
4114 DCR C
4115
4116 JNZ L1
4117
4118 MOV D,A
4119
411A LDA BUFFER
411B
411C
ANI 0F
411D
Data in D reg added with
411E ADD D
A. result stored in A reg
VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 27

411F MOV M,A


4120 INX H
4121 DCR B
4122
4123 JNZ L2
4124
4125/START
MVI A,90
4126
4127
OUT 01
4128
4129
412A LXI H,DATA
412B
412C
MVI B,03
412D
412E
MVI C,18
412F
4130/ L3 MOV A,M
4131
4132 CALL C1
4133
4134
4135 CALL CONVERT
4136
4137
4138 CALL DISLAY
4139
413A INX H
413B
MVI A,18
413C
413D
ADI 24
413E
413F MOV C,A
4140 DCR B
4141
4142 JNZ L3
4143
VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 28

4144
4145 JMP DELAY
4146
4147 CMP C
4148 RNZ
4119 SUB C
414A MOV M,A
414B RET
414C/ CONVERT
MVI D,0
414D
414E/ LO1:
SUI 0A
414F
4150
4151 JC LO2
4152
4153 INR D
4154
4155 JMP LO1
4156
4157/ LO2
ADI 0A
4158
4159
415A STA BUFFER
415B
415C MOV A,D
415D RRC
415E RRC
415F RRC
4160 RRC
4161 MOV D,A
4162
4163 LDA BUFFER
4164
4165 ADD D
4166 RET
4167/ DISLAY
STA BUFFER
4168
VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 29

4169
416A
ANI FO
416B
416C RLC
416D RLC
416E RLC
416F RLC
4170
4171 CALL D1
4172
4173
4174 LDA BUFFER
4175
4176
ANI 0F
4177
4178
4179 CALL D1
417A
417B RET
417C/ D1
417D LXI D,TABLE
417E
417F ADD E
4180 MOV E,A
4181 LDAX D
4182
OUT 00
4183
4184 RET
4185 / DELAY
MVI C,2
4186
4187
MVI A,30
4188
4189
OUT OB
418A
418B/ LO4:
MVI A,90
418C
418D OUT 08
VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 30

418E
418F
MVI A,80
4190
4191
OUT 08
4192
4193/ LO3:
MVI A,0
4194
4195
OUT 0B
4196
4197
IN 08
4198
4199 MOV E,A
419A
IN 08
419B
419C ORA E
419D
419E JNZ LO3
419F
41A0 DCR C
41A1
41A2 JNZ LO4
41A3
41A4 DCX H
41A5 INR M
41A6 MOV A,M
41A7
CPI 3C
41A8
41A9
41AA JNZ START
41AB
41AC
SUI 3C
41AD
41AE MOV M,A
41AF DCX H
41B0 INR M
41B1 MOV A,M
41B2 CPI 3C
VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 31

41B3
41B4
41B5 JNZ START
41B6
41B7
SUI 3C
41B8
41B9 MOV M,A
41BA DCX H
41BB INR M
41BC MOV A,M
41BD
CPI 18
41BE
41BF
41C0 JNZ START
41C1
41C2
SUI 18
41C3
41C4 MOV M,A
41C5
41C6 JMP START
41C7
41C8/ TABLE:
41C9
DB 0A,9F,49,0D
41CA
41CB
41CC
41CD
DB 9C,2C,28,8F
41CE
41CF
41D0
41D1
DB 08,8C,88,38
41D2
41D3
41D4
41D5
DB 6A,19,68,E8
41D6
41D7
VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 32

41D8 END

Calculations :

Clock frequency F=2MHz


T-State =Clock Period (1/F) = 0.5µs
Execution time for Opcode Fetch: (4T)*0.5= 2 µs
Execution time for Memory Read: (3T)*0.5= 1.5 µs
Execution time for Instruction: (7T)*0.5= 3.5 µs

Total No. of T States:


If condition true:
If condition false:

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 33

Observation:

INPUT OUTPUT

4250
4251
4252

Conclusion:

Thus an ALP was written for real time clock . Second in data field, minutes and hours in
address field was displayed using 8085p kits.

……………………………………………………………………………………………………………………………

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 34

Questions:

1. What type of architecture used in 8085 microprocessor?

2. What is the function of accumulator?

3. What are the different types of flags in 8085 microprocessor?

4. What are the types of general purpose registers in 8085?

5. What is the length of stack pointer in 8085 microprocessor?

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 35

Lab Exercises:

1. Write a program to generate a clock where hours, minutes and sec given in following
memory location respectively 4500,4501 and 4502.

2. Write a program to generate a clock for 10 min instead of 24 hours.

3. Write a program to generate a clock of 22H: 15M: 12S given in following memory
location respectively 4300,4301 and 4302.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 36

3.TRAFFIC LIGHT INTERFACING (8085)

Aim:
To write an Assembly language Program for traffic light controller.

.
Equipment and Components Required:

8085 microprocessor kit and Power Supply.

Algorithm:

 Start.

 Write the control word to initialize 8255.Obtain the data for each direction and

store in the memory.

 Initialize a counter to indicate the number of directions

 Initialize HL Pair to the starting address of the data..

 Check the result.

 Decrement the counter and repeat step 3 till counter becomes zero.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 37

Flow Chart:

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 38

Program:

LABEL MNEMONICS BYTES MACHINE T-STATES EXECUTION


ADDRESS OPERAND OPCODE COMMENTS
CYCLES TIME
4200 MVI
A, 80H
4201
4202 OUT
83H (CR)
4203
4204 START MVI A, 09H
4205

4206
OUT 80H (PA)
4207
4208
MVI A, 24H
4209

420A OUT
81H (PB)
420B
420C MVI
C, 28H
420D

420E CALL
DELAY
420F
VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 39

4210
4211
NOP

4212
CPI 3CH
4213

4214
MVI A, 12H
4215

4216
OUT (81H) PA
4217
4218
OUT (81H) PB
4219

421A
MVI C, 0AH
421B

421C

421D DELAY
CALL
421E

421F MVI
A, 24H
4220
VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 40

4221
OUT (80H) PA
4222
4223 MVI A, 09H
4224
4225
OUT (81H) PB
4226

4227 C, 28H
MVI

4228 CALL DELAY

422A MVI A, 12H

422C PA
OUT

422E PB
OUT
4230 MVI C, 0AH

4232 CALL DELAY


JMP START
4234

4237 D, Count

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 41

DELAY LXI

423A D
BACK DCX
MOV A, D
423D

423E ORA E

423F BACK
JNZ

4240 C
DCR
JNZ DELAY
4243

4244 RET

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 42

Traffic Light Model:

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 43

Conclusion:
Thus an ALP was written for traffic light controller using 8085p kits.

…………………………………………………………………………………….…………………………………………………

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 44

Questions:

1. Draw the control word register.

2. List the ports in 8255.

3. What are modes available in 8255?

4. How to initialize 8255?

5. Give the significance of SIM and RIM instruction available in 8085.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 45

Lab Exercises:

1. Write an Assembly language program for controlling traffic in a three lane junction
using 8085.

2. Write an Assembly language program for controlling traffic in 4 lane junction with
green light on time 60 seconds and red light on time 180 seconds for each lane using
8085.

3. Write an Assembly language program to interface RTC with traffic control system for
effective control during the peak time.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 46

4.PROGRAMS FOR ALU OPERATIONS (8086)


A) 16-BIT DATA ADDITION-8086
Aim:
To write a program to add two 16-bit numbers using 8086.
.

Equipment and Components Required:

8086 Microprocessor kit, Power Supply

Algorithm:

 Start the program.

 Initialize the memory locations with input data.

 Load the values from memory location to the registers..

 Add the two values stored in the registers.

 If carry occurs (CF=1) increment the carry storing register and store the sum and

carry in the memory location. Otherwise store the sum in the memory location.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 47

Flow chart:

Start

Clear CL Register

Get the content of


1100H &1101H in AX

Get the content of


1102H &1103H in BX

Perform Addition
[AX]=[AX]+[BX]

NO
Is
CF=1
?
YES

Increment CL
Register

Store the Content of


CL register to 1106H

Store the Result


[1104]=[AL],[1105]=[AH]

End

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 48

BYTE MACHINE T- EXECUTION


ADDRESS LABEL MNEMONICS OPERAND OPCODE COMMENTS
S CYCLES STATES TIME
1000 START MOV CL,00H
1001
1002
MOV AX, [1100]
1003
1004
1005
1006 MOV BX, [1102]
1007
1008 ADD AX, BX
1009
100A JNC L1
100B
100C INC CL
100D
100E L1 MOV [1104], AX
100F
1010
1011 MOV [1106], CL
1012
1013 HLT

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 49

Observation:

INPUT OUTPUT
ADDRESS 1100 1101 1102 1103 1104 1105 1106 1107
DATA1
DATA2

Conclusion:

Thus the 16 bit numbers stored in memory location are added and the result stored in
another memory location using 8086p kits.

………………………………………………………………………………………………………………………………………..

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 50

Questions:

1. What are the features of 8086 Microprocessor?

2. What is the function of accumulator?

3. What are the different types of flags available in 8086 microprocessor?

4. List the general purpose registers in 8086?

5. What type of architecture used in 8086 microprocessor?

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 51

B) 16-BIT DATA SUBTRACTION-8086


Aim:
To write a program to subtract two 16-bit numbers using 8086.
.

Equipment and Components Required:

8086 Microprocessor kit, Power Supply

Algorithm:

 Start the program.

 Initialize the memory locations with input data.

 Load the values from memory location to the registers..

 Subtract the two values stored in the registers.

 If carry occurs (CF=1) increment the carry storing register and store the difference

and borrow in the memory location. Otherwise store the difference in the memory

location.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 52

Flow chart:

Start

Clear CL Register

Get the content of


1100H &1101H in AX

Get the content of


1102H &1103H in BX

Perform Subtraction
[AX]=[AX]-[BX]

NO
Is
CF=1
?
YES

Increment CL
Register

Store the Content of


CL register to 1106H

Store the Result


[1104]=[AL],[1105]=[AH]

End

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 53

MACHINE T- EXECUTION
ADDRESS LABEL MNEMONICS OPERAND OPCODE BYTES COMMENTS
CYCLES STATES TIME
1000 START MOV CL,00H
1001
1002
MOV AX, [1100]
1003
1004
1005
1006 MOV BX, [1102]
1007
1008 SUB AX, BX
1009
100A JNC L1
100B
100C INC CL
100D
100E L1 MOV [1104], AX
100F
1010
1011 MOV [1106], CL
1012
1013 HLT

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 54

Observation:

INPUT OUTPUT
ADDRESS 1100 1101 1102 1103 1104 1105 1106 1107
DATA1
DATA2

Conclusion:

Thus the 16 bit numbers stored in memory location are subtracted and the result stored
in another memory location using 8086p kits.

………………………………………………………………………………………………………………………………………..

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 55

Questions:

1. What are the two types of conditional jumps?

2. Write short notes on Pointers and Index Group of Registers?

3. List the types of interrupts.

4. What happens when interrupt occurs?

5. Compare 8086 and 8088.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 56

D) 16-BIT DATA MULTIPLICATION-8086


Aim:
To write a program to perform multiplication of two 16 bit number using 8086.

Equipment and Components Required:

8086 Microprocessor kit, Power supply.

Algorithm:

 Start the program.

 Initialize the memory locations with multiplier and multiplicand.

 Load the values from memory locations to the registers..

 Multiply the two 16 bit data stored in the registers.

 Store the product in the memory location.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 57

Flow chart:

Start

Clear CL register

Store the Data1 in


AX register

Store the Data2 in


BX register

Perform
Multiplication
[AX]=[AX]*[BX]]
[DX]=R[[DX][AX]/[BX]]
Store the results in
to memory

End

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 58

ADDRESS/ MACHINE EXECUTION COMMENTS


LABEL MNEMONICS OPERAND OPCODE BYTES T-STATES
LABEL CYCLES TIME
1000 START MOV CL, 00H
1001
1002
MOV AX, [1100]
1003
1004
1005
1006 MOV BX, [1102]
1007
1008 MUL BX

1009
100A MOV [1104], AX
100B
100C
100D MOV [1106], DX
100E
1010 HLT

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 59

Observation:

INPUT OUTPUT
ADDRESS 1100 1101 1102 1103 1104 1105 1106 1107
DATA1
DATA2

Conclusion:

Thus the 16 bit numbers stored in memory location are multiplied and the result stored in
another memory location using 8086p kits.

………………………………………………………………………………………………………………………………………..

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 60

Questions:

1. List the various logical operations performed by the 8086?

2. How will you perform multiplication without using the MUL instruction?

3. What are the various jump instructions available in 8086 instruction set?

4. Write short notes on zero flag.

5. Define Program Counter.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 61

E) 32-BIT DATA DIVISION-8086


Aim:
To write a program to perform division of a 32 bit number by a 16 bit number using 8086.

Equipment and Components Required:

8086 Microprocessor kit, Power Supply

Algorithm:

 Start the program.

 Initialize the memory locations with divider and dividend.

 Load the values from memory locations to the registers..

 Divide the 32 bit data stored in the registers by the 16 bit data stored in the GP

register.

 Store the quotient and reminder in the memory location.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 62

Flow chart:

Start

Store the lower word


of Dividend in AX

Store the Higher word


of Dividend in DX

Store the Divider in BX

Perform Division
[AX]=Q[[DX][AX]/[BX]]
[DX]=R[[DX][AX]/[BX]]

Store the results in


to memory

End

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 63

ADDRESS/ MACHINE EXECUTION COMMENTS


LABEL MNEMONICS OPERAND OPCODE BYTES T-STATES
LABEL CYCLES TIME
1000
1001 START MOV AX, [1100]
1002
1003
MOV DX, [1102]
1004
1005
1006
1007 MOV BX, [1104]
1008
1009 DIV BX

100A
100B MOV [1106], AX
100C
100D
100E MOV [1108], DX
1010
1011 HLT

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 64

Observation:

INPUT OUTPUT
ADDRESS 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109
DATA1
DATA2

Conclusion:

Thus the 16 bit numbers stored in memory location are divided and the result stored in
another memory location using 8086p kits.

………………………………………………………………………………………………………………………………………..

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 65

Questions:

1. Write short notes on parity flag.

2. List the general purpose registers in 8086?

3. What type of architecture used in 8086 microprocessor?

4. What are the various addressing modes of 8086?

5. Draw the Flag register of 8086.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 66

Lab Exercises:

1. Write an Assembly language program to perform 8-bit addition, subtraction,


multiplication and division using 8086.

2. Write an Assembly language program to add two 32 bit numbers stored as double
words in 8 consecutive memory locations are to be added and the result stored as a
double word in memory using 8086.

3. Write an Assembly language program to convert the number FFFFH to its decimal
equivalent and store the result in memory using 8086.

4. Write an Assembly language program to perform multiplication and division by


powers of 2 using the arithmetic shift instructions using 8086.

5. Write an Assembly language program to perform XOR operation on a 16 bit hexa


decimal number using 8086.

6. Write an Assembly language program to perform NAND operation on a 16 bit hexa


decimal number using 8086.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 67

5.PROGRAM FOR SQUARE ROOT AND SQUARE


OF THE GIVEN INPUT (8086)
Aim:
To write the programme for find the square the root and square of given number using
8086.

Equipment and Components Required:

8086 Microprocessor kit, Power Supply

Algorithm:(square)

 Start the program.

 Initialize Source Index and Destination address.

 Load the values from source index to the registers..

 Multiply the two 16 bit data stored in the registers.

 Store the product in the destination address.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 68

Algorithm:(square root)

 Start the program.

 Initialize Source Index and Destination address.

 Load the values from source index to the registers.

 Initialize CX=0001 and BX=0000.

 Subtract CX from AX. If AX is greater than CX, increment CX by 02, and BL also

increment by 01 do the same process until Carry generate.

 Once carry generate, the data in the BL reg stored in Destination address.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 69

Flow chart: (square)

Start

Clear CL register

Store the Data1 in


AX register

Store the Data1 in


BX register

Perform
Multiplication
[AX]=[AX]*[BX]]
[DX]=R[[DX][AX]/[BX]]
Store the results in
to memory

End

Program:

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 70

ADDRESS/ MACHINE EXECUTION COMMENTS


LABEL MNEMONICS OPERAND OPCODE BYTES T-STATES
LABEL CYCLES TIME
1000
START MOV CL, 00H
1001
1002
1003 MOV AX, [1100]
1004
1005
1006
MOV BX,AX
1007

1008
MUL BX
1009
100A
100B MOV [1104], AX
100C
100D
100E
100F MOV [1106], DX
1010
1011
1012 HLT

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 71

Observation:

INPUT OUTPUT

1100 1104
1101 1106

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 72

Flow chart: (square)

Start

Move the data to AX


reg

Move address of data to SI


Move address of result to DI

Initialize
CX=0001,BX=0000.

[AL]-[BL] [AL]
[CL]+02 [CL]

YES
IF
Increment the
[AL]>[B
data in BL reg
L]

NO

Move the data from


BL reg to DI

End

Program:

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 73

ADDRESS/ MACHINE EXECUTION COMMENTS


LABEL MNEMONICS OPERAND OPCODE BYTES T-STATES
LABEL CYCLES TIME
1000
START MOV AX,DATA
1001
1002
1003 MOV DS,AX
1004
1005
1006 SI,OFFSET
MOV
DATA1
1007

1008 DI,OFFSET
MUL
RES
1009
100A
100B MOV CX,0001
100C
100D
100E
100F MOV BX,0000
1010
1011
1012 MOV AL,[SI]
1013
1014 UP SUB AL,CL
1015

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 74

1016 JC DOWN
1017 INC BL

1018 ADD CL,02


1019 JMP UP
1020 MOV
DOWN (DI),BL
1021
1022 INT 03

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 75

Observation:

INPUT OUTPUT

1100 1104
1101 1106

Conclusion:

Thus an ALP was written for 16-bit square the root and square of given number and
executed using 8086p kits

………………………………………………………………………………………………………………………………………..

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 76

Questions:

1. Give the significance of 8086.

2. Define STACK.

3. Compare 8085 And 8086

4. What is the maximum capacity of memory that can be identified with 8086?

5. What is the difference between RAR and RAL instructions in 8086?

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 77

Lab Exercise:

1. Write a program to find the square of a given number which is stored in memory
location 1102 and store the result in 1107 using 8086kit.

2. Write a program to find the square root of a given number which is stored in
memory location 1104 and store the result in 1108 using 8086kit.

3. Write a program to find the square of a given number which is stored in memory
location 1101 and store the result in 1107 using 8086kit.

4. Write a program to find the square and cube of a given number which is stored in
memory location 1101 and store the result in 1107, 1108 using 8086kit.

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 78

6. INTERFACING OF STEPPER MOTOR USING 8086


Aim:
To write an assembly language program for running a stepper motor using 8086.

.
Equipment and Components Required:

8086 Microprocessor kit, Stepper motor, Driver circuit.

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, and 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. The commonly used switching
scheme is two – phase switching scheme which is shown below

CLOCKWISE ANTICLOCKWISE

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


1 1 0 0 1 09H 1 1 0 1 0 0AH
2 0 1 0 1 05H 2 0 1 1 0 06H
3 0 1 1 0 06H 3 0 1 0 1 05H
4 1 0 1 0 0AH 4 1 0 0 1 09H

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 79

The step angle of the stepper motor available in the laboratory is 1.80

As per I/O decoding given by the manufacturer, the 8-bit address for sending data is
C0H

PROGRAM 1:

To run the stepper motor at different speeds

Look up Table:

1100 1101 1102 1103


09 05 06 0A

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 80

MNEMONIC MACHINE T- EXECUTION


ADDRESS LABEL OPERAND OPCODE BYTES COMMENTS
S CYCLES STATES TIME
1000
1001 L2 MOV SI, 1100H
1002
1003 MOV BL, 04H
1004
1005 L1 MOV AL, [SI]
1006 OUT 0C0H, AL
1007
1008
1009 CALL DELAY
100A
100B INC SI
100C DEC BL

100D
100E JNZ L1
100F
1010
1011 JMP L2
1012
1013 DELAY MOV CX, 00FFH

1014
1015 HERE LOOP HERE
1016
1017 RET

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 81

PROGRAM 2:

To run the stepper motor in clockwise direction for one revolution

Look up Table:

1100 1101 1102 1103


09 05 06 0A

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 82

MACHINE T- EXECUTION
ADDRESS LABEL MNEMONICS OPERAND OPCODE BYTES COMMENTS
CYCLES STATES TIME
1000 MOV BL, 32H
1001
1002 L2 MOV DL, 04H
1003
1004
1005 MOV SI, 1100H
1006
1007 L1 MOV AL, [SI]

1008 OUT 0C0H, AL


1009
100A
100B CALL DELAY
100C
100D INC SI

100E DEC DL
1011
1012 JNZ L1
1013
DEC BL
1014
1015
1016 JNZ L2
1017

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 83

1018 HLT

VTU R 2015 Department of ECE Veltech Dr. RR & Dr. SR University


Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 84

Conclusion:

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

………………………………………………………………………………………………………………………………………..

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 85

Questions:

1. In a two phase bipolar stepper motor, how many field coils are placed?

2. What is meant by Holding Torque?

3. In a stepper motor the speed is directly proportional to the frequency of input


electrical pulses?

4. Find the step angle of a three phase stepper motor which 12 rotor teeth in it?

5. The three phase stepper motor consists of 4 teeth in its rotor. How many steps are
required by the motor to complete one full revolution?

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 86

Lab Exercises:

1. Write a program for a stepper motor to rotate it continuously.

2. Write a program to rotate a motor 700 in the clockwise direction. The motor has a step
angle of 70 .

3. Write a program in ALP to interface stepper motor to 8086 and rotate it in anti-
clockwise direction.

4. Write a program in ALP to interface stepper motor to 8086 and rotate it in clockwise
direction.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 87

7.PROGRAM FOR ALU OPERATION (8051)


Aim:
To write a program to do the arithmetic operations using 8051 microcontroller.

Equipment and Components Required:

Power supply, 8051 kit

Algorithm:

 Step 1 : Move 1H data to memory

 Step 2 : Add or subtract 1H data with 2nd data

 Step 3 : Initialize data pointer.

 Step 4 : Move result to memory pointed by DPTR.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 88

Flow chart:

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 89

Program:
8-bit Addition:
BYTES MACHINE EXECUTION TIME COMMENTS
ADDRESS/LABEL MNEMONICS OPERAND OPCODE T-STATES
CYCLES
4100 CLR C
4101 MOV A
4102
4103 ADD A
4104
4105 MOV DPTR
4106
4107
4108 MOV A
4109 SJMP 4109

Execution:

Addition:

ML Input
ML Output
4103 0L
4500 05
4109 03

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 90

Program:
8-bit Subtraction:
BYTES MACHINE EXECUTION TIME COMMENTS
ADDRESS/LABEL MNEMONICS OPERAND OPCODE T-STATES
CYCLES
4100 CLR C
4101 MOV A
4102
4103 SUB B
4104
4105 MOV DPTR
4106
4107
4108 MOV X@DTPR,A
4109 SJMP 4109

Execution:
Subtraction:

ML Input ML Output

4101 05 4500 03

4103 02

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 91

Calculations :

Crystal Oscillator frequency of 8051 = 11.0529MHz


With respect to clock cycle = 11.0529/12 = 921.6 KHz
For One Machine Cycle (Time) = (1/F) =1/ 921.6 = 1.085

Observation:
Addition:

INPUT OUTPUT

4103 4500
4109

Subtraction:

INPUT OUTPUT

4101 4500
4103

Conclusion:

Thus an ALP was written for arithmetic operations using 8051 microcontroller and executed
using 8051 controller kit.

……………………………………………………………………………………………………………………………

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 92

Questions:

1. Which control signals of 8051 are used to access external data memory and external
program memory

2. State any two applications of 8051

3. How does 8051 differentiate between external and internal program memory?

4. What is the use of DTPR?

5. What are the addressing modes supported by 8051.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 93

Lab Exercises:

1. Two numbers are stored in registers R0 and R1. Verify if their sum is greater than
FFH.

2. Write programs to add two 16-bit numbers, the numbers are FC45H and 02ECH.

3. Write programs to add two 32-bit numbers stored in RAM locations.

4. Assume that 5BCD data items are stored in RAM locations starting at 40H,as shown
below. Write a program to find the sum of the numbers. The result must be in BCD.
a. 40= (71)
b. 41= (11)
c. 42= (65)
d. 43= (59)
e. 44= (37)

5. In a semester, a student has to take six courses. The marks of the student (out of 25)
are stored in RAM locations 47H onwards. Find the average marks, and output it on
port 1.

6. Convert a Hexadecimal number to decimal.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 94

8. PROGRAM FOR BIT MANIPULATION AND MASKING


FOR THE GIVEN INPUT (8051)

Aim:
To write ALP for performing Bit manipulation and masking operations in 8051
.

Equipment and Components Required:

Power supply, 8051 kit

Algorithm:
Multiplication / Division:

 Initialize content of accumulator as FFH


 Set carry flag (cy = 1).
 AND bit 7 of accumulator with cy and store PSW format.
 OR bit 6 of PSW and store the PSW format.
 Set bit 5 of SCON.
 Clear bit 1 of SCON.
 Move SCON.1 to carry register.
 Stop the execution of program

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 95

Flow chart:

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 96

Program:

ADDRESS/LABEL MNEMONICS OPERAND OPCODE BYTES MACHINE CYCLES T-STATES EXECUTION TIME COMMENTS
4100 MOV DPTR
4102 MOV X A DPTR
4103 MOV R0,0FFH
4104 MOV 0FFH,A;
4105 MOV A, R0
4107 MOV X @DPTR, A

Observation:

INPUT OUTPUT

4102 4500
4107

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 97

Calculations :

Crystal Oscillator frequency of 8051 = 11.0529MHz


With respect to clock cycle = 11.0529/12 = 921.6 KHz
For One Machine Cycle (Time) = (1/F) =1/ 921.6 = 1.085 μs

Conclusion:

Thus an ALP was written for 8 Bit manipulation and masking operations in 8051

……………………………………………………………………………………………………………………………

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 98

Questions:

1. What happens in power down mode of 8051 micro controller?

2. What is that register addressing mode in 8051 microcontroller?

3. Name the two external interrupt of 8051 microcontroller.

4. Specify any two applications of Microcontrollers.

5. What do you mean by Indirect Addressing Mode?

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 99

Lab Exercises:

1. Write a program to create a square wave of 50 % duty cycle on bit 0 of port 1.

2. Write a program to create a square wave of 66 % duty Cycle on bit 3 of port 1.

3. A switch is connected to pin P1.7.Write a program to check the status of SW and


perform the following:
If SW = 0, send letter ‘N’ to P2.
If SW = 1, send letter ‘Y’ to P2.

4. A switch is connected to pin P1.0 and an LED to Pin P2.7. Write a program to get the
status of the switch and send it to the LED.

5. Write a program to take in data through P1.0 and send it through P2.7.

6. Mask off the LN of memory location 4150 and place the result at 4151.

7. Mask off the 7th and 3rd bits of register H which contain B9. Store the result at
4150.(Use AND instruction).

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 100

9.INTERFACING OF STEPPER MOTOR WITH 8051


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

Equipment and Components Required:

8051 microcontroller kit, stepper motor, power cord.

Algorithm:

 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.

 Wait for an interrupt. If interrupt occurs, the control has to be passed to sub-

routine by calculating interrupt vector.

 Entering the data in the look-up TABLE in the reverse order can vary Direction of

rotation.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 101

Program:

ADDRESS/LABEL MNEMONICS OPERAND OPCODE BYTES MACHINE CYCLES T-STATES EXECUTION TIME COMMENTS
ORG 4100h

DPTR,
4100 MOV
#TABLE

4103 MOV R0, #04


4105 MOVX A, @DPTR
4106 PUSH DPH
4108 PUSH DPL
DPTR,
410A MOV
#0FFC0h
410D MOVX @DPTR, A
410E MOV R4, #0FFh
4110 MOV R5, #0FFh
R5,
4112 DJNZ
DELAY1
R4,
4114 DJNZ
DELAY
4116 POP DPL
4118 POP DPH
411A INC DPTR

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 102

411B DJNZ R0, LOOP


411D SJMP START
09 05 06
411F DB
0Ah

Lookup Table:

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

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

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 103

Calculations :

Crystal Oscillator frequency of 8051 = 11.0529MHz


With respect to clock cycle = 11.0529/12 = 921.6 KHz
For One Machine Cycle (Time) = (1/F) =1/ 921.6 = 1.085μs

Conclusion:

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

……………………………………………………………………………………………………………………………

VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 104

Questions:

1. 1. How many no. of interrupts available for 8051?

2. Which is the highest priority interrupt for 8051?

3. What are an ISR and IVT?

4. What is the difference between software and hardware interrupt?

5. What is the vector address for serial communication interrupt?

VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 105

Lab Exercises:

1. Write a program for a stepper motor to rotate it continuously.

2. Write a program to rotate a motor 640 in the clockwise direction. The motor has a step
angle of 20 .

3. A switch is connected to pin P2.7. Write a program to monitor the status of SW and
perform if SW= 0, the stepper motor moves clockwise.

4. A switch is connected to pin P2.7. Write a program to monitor the status of SW and
perform if SW = 1, the stepper motor moves counter clockwise.

5. A switch is connected to pin P2.7. Using a simulator , write a program to monitor the
status of SW and perform the following
If SW= 0, the motor moves clockwise.
If SW =1, the motor moves counter clockwise.

VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 106

10.ADC AND DAC INTERFACING USING 8051


MICROCONTROLLER
Aim:
To write a Assembly language program to interface ADC and DAC using 8051.

.
Equipment and Components Required:

8051 microcontroller kit, 8255 interface, Power cord

Algorithm:

 Initialize the control word register i.e., 8255 as input port.

 Send 00 to port A of 8255

 Call delay subroutine

 Send FF to port A of 8255

 Call delay subroutine

 Repeat the step 2 onwards.

Saw tooth wave form:

 Initialize the control word register.

 Initialize the accumulator content

 Send to port A of 8255

 Increment the accumulator content

 If zero flag is not set then repeat the step 3 onwards, otherwise repeat the

step 2 onwards.

VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 107

Flow chart:

VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 108

Program for DAC:

LABEL MNEMONICS BYTES MACHINE T-STATES EXECUTION


ADDRESS OPERAND OPCODE COMMENTS
CYCLES TIME
6000
ORG 000h
6001
6002
MOV P1, #00H
6003
6004
repeat CALL squarewave
6005
6006
CALL triwave
6007
6008
CALL stairwave
6009
600A
JMP repeat
600B
600C square
MOV P1, #FFH
600D wave
600E
CALL delay2sec
600F
6010 RET
6011 triwav
MOV R7, #00H
6012 e
6013 triwav
MOV P1, #FF7
6014 e1
VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 109

6015 INC R7
6016 R7, #FFH,
CJNE
6017 triwave2
6018
MOV R7, #FFH
6019
triwav
601A MOV P1, R7
e2
601B
DJNZ R7, triwave2
601C
601D RET
601E stairw
MOV P1, #00H
601F ave
6020
CALL delay2sec
6021
6022
MOV P1, #20H
6023
6024
CALL delay2sec
6025
6026
MOV P1, #40H
6027
6028
CALL delay2sec
6029
602A
MOV P1, #80H
602B
VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 110

602C
CALL delay2sec
602D
602E RET
602F delay1
MOV r0, #10
6030 sec
6031
del2 MOV r1, #250
6032
6033
del1 MOV r2, #250
6034
6035 DJNZ r2, $
6036
DJNZ r1, del21
6037
6038
DJNZ r0, del22
6039
603A RET

603B END

VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 111

Observation:

DATA OUTPUT VOLTAGE

VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 112

Program for ADC:

LABEL MNEMONICS BYTES MACHINE T-STATES EXECUTION


ADDRESS OPERAND COMMENTS
OPCODE CYCLES TIME
6100 MOV SI, 1100H
6101
6102
6103 MOV AL, 10H
6104
6105 OUT 0C8H, AL
6106
6107 MOV AL, 18H
6108
6109 OUT 0C8H, AL
610A
610B MOV AL, 01H
610C
610D OUT 0D0H, AL
610E
610F MOV AL, 00H
6110
6111 MOV AL, 00H
6112

VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 113

6113 MOV AL, 00H


6114
6115 MOV AL, 00H
6116

6117 OUT 0D0H, AL


6118

6119 IN AL, 0D8H


L1
611A
611B AND AL, 01H

611C
611D CMP AL, 01H
611E
611F JNZ L1
6120
6121 IN AL, 0C0H
6122
6123 MOV [SI], AL
6124
HLT
6125

VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 114

Observation:

DIGITAL OUTPUT
SL.NO VOLTAGE INPUT
( IN HEXADECIMAL)

Conclusion:

Thus the assembly language program for interface ADC and DAC was written and verified
using 8051.

……………………………………………………………………………………………………………………………

VTU R 2015, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 115

Questions:

1. What are the internal devices of a typical DAC?

2. Why do we need relay interface?

3. What is settling or conversion time in DAC?

4 What are the different types of ADC?

5. Give the format of program clock word of 8279 and mention its purpose.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 116

Lab Exercise:

1. Write an assembly language program for DAC that generates a saw tooth
wave at the output of the DAC at channel 0

2. Write an assembly language program for ADC that initializes the channel and
read the digital data.

3. Write an assembly language program to read the data from channel and
display the digital data in the seven segment display

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 117

11.KEYBOARD AND DISPLAY INTERFACE WITH


8051
Aim:
Write a ALP to initialize 8279 and to display the rolling message 'HELP US' in the
display. However, before sending codes to the display RAM, a write display RAM control
word should be sent. Then, write the data to be displayed, to the data register.

Equipment and Components Required:

8051 microcontroller kit, 8279 interface board, Power cord

Algorithm:

 Start the program

 Initialize the lookup table pointer and counter.

 Initialize keyboard and display mode 8279.

 Initialize pre scalar count.

 Initialize 8279 in display RAM write mode.

 Get 7 segment code.

 Write 7 segment code in the display RAM

 Increment lookup table pointer.

 Decrement counter.

 Display value.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 118

Flow chart:

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 119

Program:

ADDRESS/ MACHINE EXECUTION


MNEMONICS OPERAND OPCODE BYTES T-STATES COMMENTS
LABEL CYCLES TIME
9100 MOV DPTR,#40A2

9103 MOV A,#00

9105 MOVX @DPTR,A


9106 MOV A,#CC
9108 MOVX @DPTR,A

9109 MOV A,#90

910B MOVX @DPTR,A


910C MOV DPTR,#40A0
910F MOV A,#88
9111 MOVX @DPTR,A
9112 MOV R0,#05
9114 MOV A,#FF
9116 LOOP: MOVX @DPTR,A
9117 DJNZ R0,LOOP
HERE: SJMP
9119
HERE

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 120

Look-Up Table:

9200 FFH FFH FFH FFH

9204 FFH FFH FFH FFH

9208 98H 68H 7CH C8H

920C FFH ICH 29H FFH

OUTPUT: HELP US

Conclusion:

Thus an ALP program interface for keyboard and data was displayed using 8051.

…………………………………………………………………………………………………………………………………………

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 121

Questions:

1. What are the tasks involved in keyboard interface?

2. How a keyboard matrix is formed in keyboard interface using 8279?

3. What is scanning in keyboard and what is scan time?

4 What is scanning in display and what is the scan time?

5. Give the format of program clock word of 8279 and mention its purpose.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 122

Lab Exercise:

1. Write an ALP program to send letters `HELLO HELP US’ to the LCD using delays.

2. Write an ALP program to send letters `VELTECH’ to the LCD using busy flag method

3. Write an ALP program to send letters `WELCOME’ to the LCD.

4. Write an ALP program to send letters `MPMC LAB’ to the LCD and verify.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 123

12. DC MOTOR INTERFACE WITH 8051


Aim:

To write a C Program to interface DC motor with 8051 Microcontroller.

Equipment and Components Required:

8051 microcontroller kit, DC Motor Interface board, Power cord

Algorithm:

 Start the program.


 Initialize port A, port B and port C as output ports.
 Move the sequence of input to port A.
 Call the delay Routine
 Execute the above steps in a while loop
 Stop the program

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 124

Flow chart:

Procedure

Open the Keil software. Click on the project and create a new project. Create a new C file and
type the program. Create the necessary header files add to the project. Compile the C file and debug
the code. Now the 8051 device is to be connected to PC. Connect the ADC interface to 26 pin FRC
connector of ECAMCB51. Run the program.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 125

Program:

/************************** DCMotor interface *****************************

Object : To demonstrate the DCMotor interface


Connection : Connect the
interface to 26 pin FRC connector of ESAMCB51
Output : When you run the
program it runs with the half speed.
To increase the speed press
P3.2/INT0 button.
To decrease the
speed press P3.3/INT1 button.

**************************************************************************/
#include <REG51xD2.H>
#include <stdio.h>

unsigned char xdata control _at_ 0xe003;


unsigned char xdata porta _at_ 0xe000;
unsigned char xdata portb _at_ 0xe001;
unsigned char xdata portc _at_ 0xe002;

void delay(unsigned char d) /* Delay routine */


{
for(;d>0;d++);

unsigned char readserial()


{

while(!RI);

RI = 0;

return SBUF;

void writeserial(unsigned char ch)

{
while(!TI);

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 126

SBUF=ch;

TI=0;

unsigned char MeasureSpeed() /* Routine for measuring speed*/

unsigned char SpdCnt=0x0;

while(portb&0x02) /* wait for one time pulse */

while(!(portb&0x02));

do

while(portb&0x01); /* wait for speed pulse gets low */

SpdCnt++; /* Increment count */

delay(10);

while(!(portb&0x01)); /* wait for speed pulse gets high */

delay(10);

} while(portb&0x02); /* do until one time pulse */

return(SpdCnt); /* return speed */

void main()

unsigned char flag = 2,Cnt=0x7f,Spd,ch;

SCON = 0x52 /* SCON: mode 1, 8-bit UART, enable rcvr */

TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */

TH1 = 0xe6; /* TH1: reload value for 1200 baud @ 16MHz */

TR1 = 1; /* TR1: timer 1 run */


TI = 1; /* TI: set TI to send first char of UART */

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 127

control=0x83;

_getkey();

printf("Speed = ");

while(1)

porta = Cnt; /* Move half count to run with half speed */

ch=readserial(); /* If user choice is for Increment */

if(ch=='i'|| ch=='I')

if(Cnt>0x1f)

Cnt-=0x10; /* Decrement count to increase Speed */

else if(ch=='d'|| ch=='D')

if(Cnt<0xe0)

Cnt+=0x10; /* Incrament count to decrease the speed */

else if(ch=='s' || ch=='S')

Spd = MeasureSpeed(); /* measure the speed */

writeserial(0x08); /* sending back space to serial port*/

writeserial(0x08);

writeserial((Spd/0x0a)+0x30);
writeserial((Spd%0x0a)+0x30);

}
VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 128

Output:

Switch= SS speed 88 rpm

Switch= II Increment speed 95rpm

Switch= DD Decrement speed 78 rpm

Conclusion:

Thus the C program for DC motor interfacing in 8051 microcontroller was written and executed.

…………………………………………………………………………………………………………………………………………

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 129

Questions:

1. List the ports in 8255.

2. What are modes available in 8255?

3. What is stall in a DC motor?

4. How do we change a DC motor’s rotation direction?

5. Why do we put a driver between the microcontroller and the DC motor?

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 130

Lab Exercise:

1. A switch is connected to pin P2.7. Using a simulator, write a program to monitor the
status of SW and perform if SW=0, the DC motor moves clockwise.

2. A switch is connected to pin P2.5. Using a simulator, write a program to monitor the
status of SW and perform if SW=1, the DC motor moves counter clockwise.

3. A switch is connected to pin P1.5. Using a simulator, write a program to monitor the
status of SW and perform verify the speed limitations.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 131

13. TIMER PROGRAMMING USING KEIL C

Aim:
To write a C program to toggle all the bits of P0 and P2 Continuously with delay using the
inverting in 8051.

Equipment and Components Required:

PC, Keil software

Algorithm:

 Start the program

 Declare the header file.

 Initializing port0 and port2 with an input value.

 Inverting the P0 value by a NOT operator.

 P2 input value is toggled by using EX-OR operation with 0xFF.

 Calling the delay of 250ms.

 The bits in P0 and P2 are toggled with the delay.

 Stop the program.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 132

Flowchart:
Start

Assign the values to


the ports
y

While
(1)
n

Stop

Invert the port 0


variables

Ex-OR the port 1


variables

Call the delay


routine

Initialize the timer


register

n
While
(TF0==0)

y
Toggle the values

Stop

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 133

Program:

#include <reg51.h>

void MSDelay(unsigned int);

void main(void)

P0=0x55;

P2=0x55;

while (1)

P0=~P0;

P2=P2^0xFF;

MSDelay(250);

Void MSDelay()

TMOD=0x01;

TL0=0x00;

TH0=0x35;

TR0=1;

while (TF0==0);

TR0=0;

TF0=0;

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 134

Observation:

Port 0

√ √ √ √

√ √ √ √

Port 2

√ √ √ √

√ √ √ √

Conclusion:

Thus the C program to toggle all the bits of P0 and P2 continuously was written and executed
in 8051.

……………………………………………………………………………………………………………………………………

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 135

Questions:

1. What is the clock source for the timers?

2. What is the function of the TMOD register?

3. What is the maximum delay that can be generated with the crystal frequency of 22MHz?

4. Auto reload mode is allowed in which mode of the timer?

5. Find out the roll over value for the timer in Mode 0, Mode 1 and Mode 2?

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 136

Lab Exercises:

1. Develop an 8051 program using KEIL simulator to toggle the Port 0 1 st pin with a
timer delay 0f 5000μs using timer 0 mode 1.

2. Develop an 8051 C program to toggle only pin PI.7 continuously every 250 ms. Use
Timer 0, mode 2 (8-bit auto-reload) to create the delay.

3. Develop an 8051 C program to toggle only bit P3.5 continuously every 700 ms. Use
Timer 1, mode 1 (16-bit) to create the delay. Test the program on the AT89C51.

4. Develop a 8051 C program to toggle all the bits of port P1 continuously with some
delay in between. Use Timer 0, 16-bit mode to generate the delay.

5. Write an 8051 C program to toggle all bits of P2 continuously every 500 ms. Use
Timer 1. mode 1 to create the delay.

6. A switch is connected to pin PI.2. Write an 8051 C program to monitor SW and create
the following frequencies on pin PI.7: SW=0: 500 Hz SW=1: 750 Hz Use Timer 0, mode
1 for both of them.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 137

14. SERIAL PORT PROGRAMMING USING KEIL C

Aim:
To write a C program to transfer the letter “A” serially at 9600 baud continuously in 8051.

on pin P2.5 .Use timer 0 to create a square wave. Assume that XTAL=24 MHZ.
Equipment and Components Required:

PC, Keil software

Algorithm:

 Start the program

 Declare the header file.

 Set the timer1 in mode 2.

 Set the baud rate to 9600.

 Set the SCON register to 50.

 Set the timers run bit.

 Start transferring the letter until timer interrupt becomes one.

 Stop the program.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 138

Flowchart:

Start

Initialize the timer


register

While
(1)

Start transferring
the letter

Stop

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 139

Program:

#include <reg51.h>

void main(void)

TMOD=0x20;

TH1=0XFD;

SCON=0x50;

TR1=1;

While of (1)

SBUF =’A’;

While(TI==0);

TI=0;

Conclusion:

Thus the C program to transfer the letter “A” serially at 9600 baud continuously in 8051 is
written and executed.

…………………………………………………….…………………………………………………………………………………

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 140

Questions:

1. With fosc= 8 MHz, what will the count that has to filled in the UBRR register to account
for the 9600 baud rate?

2. The USART in AVR based micro controllers operate at which of the following modes?

3. Which of the following parameters should the transmitter and the receiver agree upon
before starting a serial transmission?

4. What is the use of the PE and the FE bits of the UCSRA register?

5. What does RI handshaking signal refer to according to the RS232 logic?

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 141

Lab Exercises:

1. Develop an 8051 program using KEIL simulator to serially transmit the given
characters ‘INDIA’ with a baud rate of 9600 μs. Using timer 1 mode 1.

2. Develop an 8051 program using KEIL simulator to serially transmit the given
characters ‘ECE ROCKS’ with a baud rate of 4600 μs. Using timer 0 mode 1.

3. Develop an 8051 program using KEIL simulator to serially transmit the given
characters ‘WELCOME’ with a baud rate of 4600 μs. Using timer 1 mode 0.

4. Write an 8051 C program to send the two messages “Normal Speed” and “High Speed”
to the serial port. Assuming that SW is connected to pin P2.0, monitor its status and
set the baud rate as follows: SW = 0 28,800 baud rate SW = 1 56K baud rate Assume
that XTAL = 11.0592 MHz for both cases.

5. Write a C program that continuously gets a single bit of data from PI. 7 and sends it to
Pl.O in the main, while simultaneously (a) creating a square wave of 200 us period on
pin P2.5, and (b) sending letter ‘A’ to the serial port. Use Timer 0 to create the square
wave. Assume that XTAL = 11.0592 MHz. Use the 9600 baud rate.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 142

15. INTERRUPT PROGRAM USING KEIL C


Aim:
To write a programme and verify interrupt handling in 8051.

Equipment and Components Required:

PC, Keil software

Algorithm:

 Load IE register with respect to interrupts to be handled

 Load TMOD register with MOD and Timer information.

 Load timer registers

 Wait for an interrupt. If interrupt occurs, the control has to be passed to sub-

routine by calculating interrupt vector

 By executing RETI instruction the control will execute the main program.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 143

Program:
#include <regx51.h>

void delay1ms(int n)

int i=0;

while(i<=n)

TMOD=0x01;

TL0=0x00;

TH0=0x35;

TR0=1;

while(!TF0);

TR0=0;

TF0=0;

i++;

void main()

int a=0;

P2=0x00;

while(a<=256)

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 144

delay1ms(20);

P2=a;

a++;

Conclusion:

Thus the C program was written for interrupt handling in 8051and it was verified in Keil C.

………………………………………………………………………………….……………………………………………………

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 145

Questions

1. How many no. of interrupts available for 8051?

2. Which is the highest priority interrupt for 8051?

3. What are an ISR and IVT?

4. What is the difference between software and hardware interrupt?

5. What is the vector address for serial communication interrupt?

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 146

Lab Exercises:

1. Develop an 8051 program using KEIL simulator to generate the square wave in Port
1 5 th pin when interrupted and also when there is a change in Port 2 2 nd pin the
same has to be affected in Port 35 th pin with a timer delay 0f 3000μs using timer 0
mode 2.

2. Develop an 8051 program using KEIL simulator to generate the toggle input in Port
2 2 th pin when interrupted and also when there is a change in Port 2 5 nd pin the
same has to be affected in Port 1 3 th pin with a timer delay 0f 5000μs using timer 1
mode 1.

3. Develop an 8051 program using KEIL simulator to generate the toggle input in Port
1 5 th pin when interrupted and also when there is a change in Port 2 4 nd pin the
same has to be affected in Port 3 1 th pin with a timer delay 0f 4000μs using timer 1
mode 0.

4. Write a C program that continuously gets a single bit of data from PI. 7 and sends it to
Pl.O, while simultaneously creating a square wave of 200 (as period on pin P2.5. Use
timer 0 to create the square wave. Assume that XTAL = 11.0592 MHz..

5. A switch is connected to pin PI.2. Write an 8051 C program to monitor SW and create
the following frequencies on pin PI.7:SW=0: 500 Hz SW=1: 750 Hz
Use Timer 0, mode 1 for both of them.

6. Program the DS89C4xO in C to receive bytes of data serially via the second serial port
and put them in PI. Set the baud rate at 9600, 8-bit data, and 1 stop bit. Use Timer 1
for baud rate generation.

VTU R 2015, Dept. of ECE, Vel Tech Rangarajan Dr.Sagunthala R & D Institute of Science and Tech.

S-ar putea să vă placă și