Documente Academic
Documente Profesional
Documente Cultură
Algorithm:
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.
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]
[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
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.
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 :
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:
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
Algorithm:
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
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]
[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
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:
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:
3. What are the various interrupts in 8085 microprocessor? Which is the highest
priority 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 12
Algorithm:
Decrement multiplier
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]
[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 :
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:
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.
Algorithm:
LOGIC:
Division is done using the method Repeated subtraction.
Stop subtraction when the dividend is less than the divisor .The dividend now
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
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:
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.
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:
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.
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
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:
Algorithm:
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:
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 :
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 8085p 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:
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.
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
Aim:
To write an Assembly language Program for traffic light controller.
.
Equipment and Components Required:
Algorithm:
Start.
Write the control word to initialize 8255.Obtain the data for each direction and
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:
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
422C PA
OUT
422E PB
OUT
4230 MVI C, 0AH
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
Conclusion:
Thus an ALP was written for traffic light controller using 8085p kits.
…………………………………………………………………………………….…………………………………………………
Questions:
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.
Algorithm:
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.
Flow chart:
Start
Clear CL Register
Perform Addition
[AX]=[AX]+[BX]
NO
Is
CF=1
?
YES
Increment CL
Register
End
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 8086p kits.
………………………………………………………………………………………………………………………………………..
Questions:
Algorithm:
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.
Flow chart:
Start
Clear CL Register
Perform Subtraction
[AX]=[AX]-[BX]
NO
Is
CF=1
?
YES
Increment CL
Register
End
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
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 8086p kits.
………………………………………………………………………………………………………………………………………..
Questions:
Algorithm:
Flow chart:
Start
Clear CL register
Perform
Multiplication
[AX]=[AX]*[BX]]
[DX]=R[[DX][AX]/[BX]]
Store the results in
to memory
End
1009
100A MOV [1104], AX
100B
100C
100D MOV [1106], DX
100E
1010 HLT
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 8086p kits.
………………………………………………………………………………………………………………………………………..
Questions:
2. How will you perform multiplication without using the MUL instruction?
3. What are the various jump instructions available in 8086 instruction set?
Algorithm:
Divide the 32 bit data stored in the registers by the 16 bit data stored in the GP
register.
Flow chart:
Start
Perform Division
[AX]=Q[[DX][AX]/[BX]]
[DX]=R[[DX][AX]/[BX]]
End
100A
100B MOV [1106], AX
100C
100D
100E MOV [1108], DX
1010
1011 HLT
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 8086p kits.
………………………………………………………………………………………………………………………………………..
Questions:
Lab Exercises:
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.
Algorithm:(square)
Algorithm:(square root)
Subtract CX from AX. If AX is greater than CX, increment CX by 02, and BL also
Once carry generate, the data in the BL reg stored in Destination address.
Start
Clear CL register
Perform
Multiplication
[AX]=[AX]*[BX]]
[DX]=R[[DX][AX]/[BX]]
Store the results in
to memory
End
Program:
1008
MUL BX
1009
100A
100B MOV [1104], AX
100C
100D
100E
100F MOV [1106], DX
1010
1011
1012 HLT
Observation:
INPUT OUTPUT
1100 1104
1101 1106
Start
Initialize
CX=0001,BX=0000.
[AL]-[BL] [AL]
[CL]+02 [CL]
YES
IF
Increment the
[AL]>[B
data in BL reg
L]
NO
End
Program:
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
1016 JC DOWN
1017 INC BL
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 8086p kits
………………………………………………………………………………………………………………………………………..
Questions:
2. Define STACK.
4. What is the maximum capacity of memory that can be identified with 8086?
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.
.
Equipment and Components Required:
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
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:
Look up Table:
100D
100E JNZ L1
100F
1010
1011 JMP L2
1012
1013 DELAY MOV CX, 00FFH
1014
1015 HERE LOOP HERE
1016
1017 RET
PROGRAM 2:
Look up Table:
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]
100E DEC DL
1011
1012 JNZ L1
1013
DEC BL
1014
1015
1016 JNZ L2
1017
1018 HLT
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?
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:
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
Algorithm:
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 :
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
3. How does 8051 differentiate between external and internal program memory?
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.
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.
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
Aim:
To write ALP for performing Bit manipulation and masking operations in 8051
.
Algorithm:
Multiplication / Division:
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 :
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:
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:
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
Algorithm:
Enter the above program starting from location 4100.and execute the same
Wait for an interrupt. If interrupt occurs, the control has to be passed to sub-
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
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
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 :
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:
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:
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
.
Equipment and Components Required:
Algorithm:
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
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:
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
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
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:
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
Algorithm:
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:
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:
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:
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
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
Algorithm:
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:
**************************************************************************/
#include <REG51xD2.H>
#include <stdio.h>
while(!RI);
RI = 0;
return SBUF;
{
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;
while(!(portb&0x02));
do
delay(10);
delay(10);
void main()
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)
if(ch=='i'|| ch=='I')
if(Cnt>0x1f)
if(Cnt<0xe0)
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:
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:
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
Aim:
To write a C program to toggle all the bits of P0 and P2 Continuously with delay using the
inverting in 8051.
Algorithm:
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
While
(1)
n
Stop
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 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:
3. What is the maximum delay that can be generated with the crystal frequency of 22MHz?
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
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:
Algorithm:
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
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?
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
Algorithm:
Wait for an interrupt. If interrupt occurs, the control has to be passed to sub-
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
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.