Professional Documents
Culture Documents
Prepared by
Mr.K.Aanandha saravanan, Assistant Professor, ECE
Mr.A.Yogaraj, Assistant Professor, ECE
Mr. A.Farithkhan, Assistant Professor, ECE
Mr. R.Sanmuga Sundaram, Assistant Professor, ECE
Mr.K.Sivachander, Assistant Professor, ECE
Ms.Shameli, Assistant Professor, ECE
On
02.04.2018
Department of ECE Veltech Rangarajan Dr.Sagunthala R&D Institute of Science and Technology
1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
Table of Contents
Page
S.No Name of the Experiment
No.
Cycle -I
8 Program for bit manipulation and masking for the given input (8051) 103
Cycle -I
Department of ECE Veltech Rangarajan Dr.Sagunthala R&D Institute of Science and Technology
1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
Department of ECE Veltech Rangarajan Dr.Sagunthala R&D Institute of Science and Technology
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 1
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
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
MVI C, 00 2 2 7T Clear C reg.
4101 00 3.5 µs
4102 21
4103 LXI H, 4500 00 3 10T 5 µs Initialize HL reg. to 4500
3
4104 45
4108 D2 2/ 3 7T / 10T
Jump to location if result does not
4109 JNC L1 0C (if condition is not true (if condition is 3.5 µs / 5 µs
3 yield carry.
410A 41 / true) not true / true)
410B INR C 0C 1 1 4T 2 µs Increment C reg.
Increment HL reg. to point next
410C / L1 INX H 23 1 1 6T 3 µs
memory Location.
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 1 6T 3 µs
memory Location.
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 4
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 5
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 6
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 7
Flow Chart:
START
[C] 00H
[HL] 4500H
[A] [M]
[HL] [HL]+1
[A] [A]-[M]
Is there a NO
Borrow ?
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 8
Program:
ADDRESS/LABEL MNEMONICS OPERAND OPCODE BYTES MACHINE CYCLES T-STATES EXECUTION TIME COMMENTS
4100/START MVI C, 00 0E
2 2 7T 3.5 µs Clear C reg.
00
4102 21
LXI H, 4500
4103 00 3 3 10T 5 µs Initialize HL reg. to 4500
4104 45
4105 MOV A, M
7E 1 1 7T 3.5 µs Transfer first data to accumulator
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
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 a NO
Borrow ?
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
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
Program:
ADDRESS/LABEL MNEMONICS OPERAND OPCODE BYTES MACHINE CYCLES T-STATES EXECUTION TIME COMMENTS
4100/START 21
4101 LXI H, 4500 00 3 3 10T 5 µs Initialize HL reg. to 4500
4102 45
4103 MOV B, M 46 1 1 7T 3.5 µs Move from reg M to Reg B
Increment HL reg. to point next
4104 23 1 1 6T 3 µs
INX H memory Location.
4105 3E
MVI A, 00H 2 2 7T 3.5 µs Clear accumulator
4106 00
4107 0E
MVI C, 00H 2 2 7T 3.5 µs Clear Reg C
4108 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 16
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 17
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 18
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 19
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 20
Program:
ADDRESS/LABEL MNEMONICS OPERAND OPCODE BYTES MACHINE CYCLES T-STATES EXECUTION TIME COMMENTS
4100 MVI B,00 06
2 3.5 µs
2 7T Clear C reg.
4101 00
4106 INX H 23 1 6T 3 µs
Increment HL reg. to point next
memory Location.
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 21
410B 41
410E INX H 23 1 1 6T 3 µs
Increment HL reg. to point next
memory Location.
410F MOV M,A 77 1 2 7T 3.5 µs
Transfer the result from acc. to
memory.
4110 INX H 23 1 1 6T 3 µs
Increment HL reg. to point next
memory Location.
4111 MOV M,B 70 1 2 7T 3.5 µs Move carry to memory
4112 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 22
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 23
Questions:
1. Define microprocessor.
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 24
Lab Exercises:
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 RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 25
Aim:
To write the program that uses 8253 to generate delay od one second and runs a
digital clock using 8279..
Algorithm:
Increment seconds.
if hours reaches maximum of 24 , make hours, minutes and seconds zero else go
to step 2.
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 26
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 27
Program:
C register by 1
4115 C2 Jump if the contents is
4116 JNZ L1 13 3 2 10 3.25 non zero to the location
4117 41 L1
Move the contents of
4118 MOV D,A 57 1 1 4 1.3
accumulator to D register
4119 3A
Load the contents of
411A LDA BUFFER 00 3 4 13 4.225
buffer in accumulator
411B 43
411C E6
ANI 0F 2 2 7 2.275 AND accumulator and 0F
411D 0F
Add the contents of D and
411E ADD D 82 1 1 4 1.3
accumulator
Move the contents of
411F MOV M,A 77 1 2 7 2.275
accumulator to memory
Increment the memory
4120 INX H 23 1 1 6 1.95
location by one
Decrement the contents of
4121 DCR B 05 1 1 4 1.3
B register by 1
4122 C2 Jump if the contents is
4123 JNZ L2 05 3 2 10 3.25 non zero to the location
4124 41 L2
4125/START 3E Move the contents 90H to
MVI A,90 2 2 7 2.275
4126 90 A register
4127 D3 Move the contents of
OUT 01 2 3 10 3.25 accumulator to output
4128 01
port
4129 21
412A LXI H,DATA 50 3 3 10 3.25 Load the value of Data
412B 42
412C 06 Move the contents 03H to
MVI B,03 2 2 7 2.275
412D 03 B register
412E 0E Move the contents 18H to
MVI C,18 2 2 7 2.275
412F 18 C register
Move the contents of
4130/ L3 MOV A,M 7E 1 2 7 2.275
memory to accumulator
4131 CALL C1 CD 3 5 18 5.85 Call the subroutine C1
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 29
4132 47
4133 41
4134 CD
Call the subroutine
4135 CALL CONVERT 4C 3 5 18 5.85
Convert
4136 41
4137 CD
Call the subroutine
4138 CALL DISLAY 67 3 5 18 5.85
Display
4139 41
Increment the memory
413A INX H 23 1 1 6 1.95
location by 1
413B 3E Move the content 18H to
MVI A,18 2 2 7 2.275
413C 18 accumulator
413D C6 Add immediate the
ADI 24 2 2 7 2.275 contents of accumulator
413E 24
and 24
Move the contents of
413F MOV C,A 4F 1 1 4 1.3
accumulator to C register
Decrement the contents of
4140 DCR B 05 1 1 4 1.3
B register by 1
4141 C2 Jump if the contents is
4142 JNZ L3 30 3 3 10T 3.25 non zero to the location
4143 41 L3
4144 C3
4145 JMP DELAY 85 3 3 10 3.25 Jump to the delay location
4146 41
Compare the Accumulator
4147/C1 CMP C B9 1 1 4 1.3
contents with C register
Return to subroutine if the
4148 RNZ C0 1 3 10 3.25
contents is non zero
Subtract contents of C
4119 SUB C 91 1 1 4 1.3
register to accumulator
Move the contents of
414A MOV M,A 77 1 1 4 1.3
accumulator to Memory
414B RET C9 1 3 10 3.25 Return to the subroutine
414C/ CONVERT 16 Initialize D register with
MVI D,00 2 2 7 2.275
414D 00 00
414E/ LO1: SUI 0A D6 2 2 7 2.275 Subtract the contents of
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 30
4169 43
416A E6 AND operation with F0
ANI FO 2 2 7 2.275
416B F0 and accumulator
Rotate the contents
416C RLC 07 1 1 4 1.3 through left
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 34
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 35
Calculations :
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 36
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 RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 37
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 38
Lab Exercises:
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 39
8085 microprocessor kit, Traffic light interface kit, and Power Supply.
Algorithm:
Read data for each sequence from the memory and display it through the ports.
A SAMPLE SEQUENCE:
1. (a) Vehicles from south can go to straight or left.
(b) Vehicles from west can cross the road.
(c) Each pedestrian can cross the road.
(d) Vehicles from east no movement.
(e) Vehicles from north can go only straight.
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 40
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 41
PORT A ----- 0C
PORT B ----- 0D
PORT C ----- 0E
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 42
Program:
EXECUTION
LABEL MNEMONICS BYTES MACHINE T-STATES
ADDRESS OPERAND OPCODE TIME(μs) COMMENTS
CYCLES
4100 START LXI H,DATA 21, 00, 45 3 3 10T 3.25 Initialize HL reg.to Data
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 43
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 44
B4 88 DA B4,88,DA,6 4
450C 1.3
68 8
D8 1A E8 D8 1A E8 4
4510 1.3
46 46
E8 83 78 86 E8,83,78,86, 5
4514 74 74 1.3
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 45
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 46
Calculations :
Conclusion:
Thus an assembly language program to simulate the traffic light at an intersection using a
Traffic light interfaces was written and implemented
…………………………………………………………………………………….…………………………………………………
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 47
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 48
Lab Exercises:
3. Write a program to split a hexa data into two nibbles and store in memory.
4. Write a simple program to find the smallest among the two data stored in memory.
5. Write an Assembly language program for controlling traffic in a three lane junction
using 8085.
6. 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.
7. Write an Assembly language program to interface RTC with traffic control system
for effective control during the peak time.
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 49
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.
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 50
Flow chart:
Start
Clear CL Register
Perform Addition
[AX]=[AX]+[BX]
NO
Is
CF=1 ?
YES
Increment CL
Register
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 51
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 52
CALCULATION
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.
………………………………………………………………………………………………………………………………………..
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 53
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 54
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.
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 55
Flow chart:
Start
Clear CL Register
Perform Subtraction
[AX]=[AX]-[BX]
NO
Is
CF=1 ?
YES
Increment CL
Register
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 56
MACHINE T- EXECUTION
ADDRESS LABEL MNEMONICS OPERAND OPCODE BYTES COMMENTS
CYCLES STATES TIME
1000 START MOV CL,00H 2 2 4 Clear CL reg.
1001 0.84
1002
MOV Transfer first data byte
1003 AX, [1100] 4 2 14 2.94
to accumulator
1004
1005
MOV Transfer second data
1006 BX, [1102] 4 2 14 2.94
byte to BX Register pair
1007
Subtract the contents
1008 SUB AX, BX 2 2 3 0.63 of AX and BX and store
in Accumulator
1009 Jump to location if
100A JNC L1 2 3 16/4 3.36/0.84 result does not yield
100B carry.
100C INC CL 2 2 3 0.63 Increment CL reg.
100D
Transfer the result from
100E L1 MOV [1104], AX 4 2 15 3.15
acc. to memory.
100F
1010
MOV Move the CL register
1011 [1106], CL 3 2 15 3.15
content to memory.
1012
1013 HLT 1 1 2 0.42 Stop the program
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 57
CALCULATION
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.
………………………………………………………………………………………………………………………………………..
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 58
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 59
Algorithm:
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 60
Flow chart:
Start
Clear CL register
Perform
Multiplication
[AX]=[AX]*[BX]]
[DX]=R[[DX][AX]/[BX]]
Store the results in
to memory
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 61
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 62
CALCULATION
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.
………………………………………………………………………………………………………………………………………..
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 63
Questions:
2. How will you perform multiplication without using the MUL instruction?
3. What are the various jump instructions available in 8086 instruction set?
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 64
Algorithm:
Divide the 32 bit data stored in the registers by the 16 bit data stored in the GP
register.
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 65
Flow chart:
Start
Perform Division
[AX]=Q[[DX][AX]/[BX]]
[DX]=R[[DX][AX]/[BX]]
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 66
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 67
CALCULATION
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.
………………………………………………………………………………………………………………………………………..
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 68
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 69
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.
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 70
Algorithm: (square)
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 71
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.
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 72
Start
Clear CL register
Perform
Multiplication
[AX]=[AX]*[BX]]
[DX]=R[[DX][AX]/[BX]]
Store the results in
to memory
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 73
Program:
EXECUTION COMMENTS
ADDRESS/ MACHINE TIME
LABEL MNEMONICS OPERAND OPCODE BYTES T-STATES
LABEL CYCLES
(micro sec)
1000 MOV AX,[1100] A1 3 2 14 2.94 Move the content to AX
Register
1001 00
1002 11
1003 MUL AX,[1100] F7 4 2 130 27.3 Multiply the AX Register
with data in [1100]
1004 26
1005 00
1006 11
1007 MOV [1200],DX 87 4 2 15 3.15
1008 16
Move the result to
1009 00
memory
100A 12
100B MOV [1202],AX A3 3 2 15 3.15
100C 02
100D 12
100E HLT F4 1 1 2 0.42 End of execution
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 74
Observation:
INPUT OUTPUT
1100 1104
1101 1106
V 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 75
Start
Initialize
CX=0001,BX=0000.
[AL]-[BL] [AL]
[CL]+02 [CL]
YES
IF
Increment the [AL]>[BL]
data in BL reg
NO
End
V 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 76
V 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 77
Program:
1018 00
1019 12
1020 HLT F4 1 1 2 0.42 End of execution
V 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 79
V 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 80
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
………………………………………………………………………………………………………………………………………..
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 81
Questions:
2. Define STACK.
4. What is the maximum capacity of memory that can be identified with 8086?
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 82
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, Dept. of ECE, Vel Tech RangarajanDr.Sagunthala R & D Institute of Science and Tech
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 83
.
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
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 84
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
Look up Table:
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 85
1 0 0 F M O V B L , 2 0 H B3, 20 2 2 7 T 1 . 4 μ s / 2 μ s Move20HtoBLregister
1 0 1 1 REVER M O V DI, OFFSET REV BF, 3B, 10 3 3 1 0 T 2 μ s MovetheinputaddresstoDIregistertorotateinreverse direction
1 0 1 4 C A L L R O T A T E 2 μ s
E8, 09, 00 3 3 1 0 T Call loop address
1 0 1 7 D E C B L FE, CB 2 1 4 T 0 . 8 μ s DecrementtheBLregisterbyone
1 0 1 9 J N Z R E V E R 75, F6 2 2 / 3 7T/10T 1 . 4 μ s / 2 μ s Jumpifnozerotoloopaddress
1 0 1 B C A L L D E L A Y E8, 12, 00 3 3 1 0 T 2 μ s Call delay subroutine
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 86
1 0 2 9 LOOP 1 D E C D X 4 A 1 1 4 T 0 . 8 μ s DecrementtheDXregisterbyone
1 0 2 A J N Z L O O P 1 75, FD 2 2 / 3 7T/10T 1 . 4 μ s / 2 μ s Jumpifnozerotoloopaddress
1 0 2 C I N C D I 4 7 1 1 4 T 0 . 8 μ s Increment DI register
1 0 2 D L O O P R E P T E2, F3 2 2 6 T 1 . 2 μ s Jump to loop address
1 0 2 F R E T C 3 1 1 4 T 0 . 8 μ s Return from subroutine
1 0 3 0 M O V DX, 0FFFFH BA, FF, FF 3 3 1 0 T 2 μ s Move FFFF to DX register
VTU R 2015
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 87
Conclusion:
Thus a stepper motor was interfaced with 8086 and run in forward and reverse directions
at various speeds.
………………………………………………………………………………………………………………………………………..
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 88
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.
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
Algorithm:
Step 3 : Add / subtract the values for multiply /Division(do the repeated
addition/subtraction)
Step 5: 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 90
Flow chart:
Start
ADD/SUB/MUL/DIV
Numners
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 91
Program:
8-bit Addition
4106 45
4107 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 92
Calculation:
Crystal Oscillator frequency of 8051 = 12MHz
Clock period = (1/F) =1us
Clock frequency = 1MHZ
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
Program:
8-bit Subtraction
4104 #Data 2
4105 MOV DPTR 96 3 2 24 24us Moves data 4500 to DPTR
4106 #4800 45
4107 00
X@DTP 1 24us Moves content of accumulator
4108 MOV F0 2 24
R,A location pointer DPTR
4109 SJMP L1 80 2 2 24 24us Jump to 4109
410A FE
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
Execution:
Addition:
ML Input
ML Output
4102 03
4500 06
4104 03
Calculation:
Crystal Oscillator frequency of 8051 = 12MHz
Clock period = (1/F) =1us
Clock frequency = 1MHZ
Execution:
Subtraction:
ML Input ML Output
4102 08 4500 04
4104 04
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
Program:
8-bit Multiplication
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
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
Calculation:
Crystal Oscillator frequency of 8051 = 12MHz
Clock period = (1/F) =1us
Clock frequency = 1MHZ
Execution:
Multiplication:
ML Input
ML Output
4102 05
4500 0F
4104 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 98
Program:
8 – Bit 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 99
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
Calculation:
Crystal Oscillator frequency of 8051 = 12MHz
Clock period = (1/F) =1us
Clock frequency = 1MHZ
Execution:
Divison:
ML Input
ML Output
4102 08
4500 02
4104 04
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 RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 101
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 RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 102
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 RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 103
Aim:
To write ALP for performing Bit manipulation and masking operations in 8051
.
Algorithm:
Bit Manipulation
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
Flow chart:
Start
Initialize DPTR
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 105
Observation:
INPUT OUTPUT
4101 03
4500 02
4103 02
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
Algorithm:
Masking
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:
Start
Initialize DPTR
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 108
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
Observation:
INPUT OUTPUT
4101 03
4500 05
4103 02
Calculations:
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
Conclusion:
Thus an ALP was written for 8Bit manipulation and masking operations in 8051
……………………………………………………………………………………………………………………………
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 111
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 RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 112
Aim:
To write an assembly language program to interface ADC and DAC using 8051.
.
Equipment and Components Required:
8051 microcontroller kit, 8255 interface, DAC Kit, Power cord, RS232 cord.
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
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
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
MACHINE EXECUTION
ADDRESS LABEL MNEMONICS OPERAND OPCODE BYTES T-STATES COMMENTS
CYCLES TIME
4100 MOV DPTR, #FFC8 90 FF C8 3 2 24T 24µsec Control Register
4103 MOV A, #10 74 10 2 1 12T 12 Select channel 0
WAIT:
4115 MOVX A, @DPTR E0 1 2 24T 24
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 116
HERE:
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 117
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 sec
Observation:
DIGITAL OUTPUT
SL.NO VOLTAGE INPUT
( IN HEXADECIMAL)
1
3
Algorithm for DAC:
Inline ports
Give low input
Output data to port
Give delay
Give high
Give high input
Output data to ports
Give delay
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 118
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 119
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 120
MOVX 1 2 24T 24
4115 A, @DPTR E0
JNB 3 2 24T 24
4116 E0, WAIT 30 E0 FC Check for EOC
MOV 3 2 24T 24
4119 DPTR, #FFC0 90 FF C0 Read ADC Data
MOVX 1 2 24T 24
411C A, @DPTR E0
MOV 3 2 24T 24
4110 DPTR, #4150 90 4150 Store the DATA IN
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 121
MOVX 1 2 24T 24
4120 @DPTR, A F0 Memory Location
HERE:
SJMP 2 2 24T 24
4121 HERE 80 FE
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 122
2.
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 123
Conclusion:
Thus the assembly language program for interface ADC and DAC was written and verified
using 8051.
……………………………………………………………………………………………………………………………
Questions:
5. Give the format of program clock word of 8279 and mention its purpose.
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 124
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 RangarajanDr.Sagunthala R & D Institute of Science and Tech.
Experiment No: …………….
Date: ……. /……. /…………… 1151EC303 MICROPROCESSOR AND MICROCONTROLLER LABORATORY 125
Algorithm:
Decrement counter.
Display value.
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 126
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
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 128
DELAY SUBROUTINE:
Look-Up 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 129
Calculations:
OUTPUT:
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
Conclusion:
Thus an ALP program interface for keyboard and data was displayed using 8051.
……………………………………………………………………………………………………………………………………
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 131
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 132
Theory:
A DC motor is any of a class of rotary electrical machines that converts direct current
electrical energy into mechanical energy. The most common types rely on the forces produced by
magnetic fields. Nearly all types of DC motors have some internal mechanism, either
electromechanical or electronic; to periodically change the direction of current flow in part of the
motor.
DC motors were the first type widely used, since they could be powered from existing
direct-current lighting power distribution systems. A DC motor's speed can be controlled over a
wide range, using either a variable supply voltage or by changing the strength of current in its field
windings. Small DC motors are used in tools, toys, and appliances.
The universal motor can operate on direct current but is a lightweight motor used for
portable power tools and appliances. Larger DC motors are used in propulsion of electric vehicles,
elevator and hoists, or in drives for steel rolling mills. The advent of power electronics has made
replacement of DC motors with AC motors possible in many applications. The principle of working
of a DC motor is that "whenever a current carrying conductor is placed in a magnetic field, it
experiences a mechanical force".
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
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
Program:
MACHINE EXECUTION
ADDRESS LABEL MNEMONICS OPERAND OPCODE BYTES T-STATES COMMENTS
CYCLES TIME
4100 MOV A,#FF 74 FF 2 1 12 13.02 μs
4101
4102
4103 MOV DPTR,#FFC0 90 FF C0 3 2 24 26.04 μs
4104
4105 MOVX @DPTR,A F0 1 2 24 26.04 μs
4106 LOO SJMP
P LOOP 80 FE 2 2 24 26.04 μs
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 135
Calculations :
Conclusion:
Thus an ALP 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 136
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 137
Lab Exercise:
1. A switch is connected to pin P2.7. 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. 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. 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 138
Aim:
To write a C program to toggle all the bits of P0 and P2 Continuously with delay
using the inverting and Ex-OR operators 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 139
Flowchart:
Start
While (1)
Stop
While n
(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 140
Program:
#include <reg51.h>
void MSDelay();
void main()
P0=0x55;
P2=0x55;
while(1)
P0=~P0;
P2=P2^0xFF;
MSDelay();
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 141
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 142
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 143
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. Developa 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 144
Aim:
To write a C program to transfer the letter “A” serially at 9600 baud continuously
in 8051.
on pin P2.5
Equipment .Use
and timer 0 toRequired:
Components create a square wave. Assume that XTAL=24 MHZ.
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 145
Flowchart:
Start
While (1)
No
Yes
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 146
rogram:
#include <reg51.h>
void main(void)
TMOD=0x20;
TH1=0XFD;
SCON=0x50;
TR1=1;
while(1)
SBUF ='A';
while(TI==0);
TI=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 147
Observation:
UART#1:
AAAAAAAAAAA
Conclusion:
Thus the C program to transfer the letter “A” serially at 9600 baud continuously in 8051 is
written and executed.
…………………………………………………….…………………………………………………………………………………
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 startinga 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 148
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 149
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 150
Flowchart:
Start
While
===(1)
Yes No
Move the data
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 151
Program:
#include <reg51.h>
sbit SW =P1^7;
void timer0(void)interrupt 1
WAVE = ~ WAVE;
void main()
SW=1;
TMOD=0x02;
TH0=0xA4;
TR0=1;
IE=0x82;
while(1)
IND =SW;
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 152
Observation:
Port 1
√ √
√ √
Port 2
Conclusion:
Thus the C program to continuously get a single bit of data from P1.7 and sends it to P1.0 while
simultaneously creating a square wave of 200micro sec period on pin P2.5 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 153
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 154
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 2nd pin the same
has to be affected in Port 35th 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 5nd pin the same
has to be affected in Port 1 3th 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 4nd pin the same
has to be affected inPort 31th 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.