Professional Documents
Culture Documents
• Create a New folder on the desktop for saving the contents of the program.
• Double click on the icon of Keil.
• Select the device for the target (Select Intel→ Select 8051 AH →Ok →No)
• Go in the project menu and click on μVision Project after this an edit window
will appear on desktop.
• Write the desired program in the editing window up to end.
• Right click on source group and select remove start up in project workspace.
• Go in the file menu and click on save as and save the program with the
extention .asm on desktop in the new folder.
• Right click on source group → Select add file to group → All file → Select file
.asm →
Select Add.
• Now go in the project menu and click on options for the target “Target1”.
• Update the frequency value (eg. 11.0592) and click on output and enable the
following.
• ®Create Executable
• √ or Ok –Debug info
• Select Create Hex file
• Select
Browse info
Now click on
Ok
• Go in the project menu and click on built target.
• Go in the project menu and click on Rebuild target.
• Go in the project menu and click on Run (or Ctrl +F5).
After this Hex file will be created in the New Folder
Experiment No.1
Aim: - To Perform basic arithmetic (Addition , Subtraction, Multiplication, Division)
and logical operations (AND,OR,X-OR) using 8051 instructions.
Objectives: -
i) Add 01 H with FF H And observe contents of Accumulator and Program
status word
ii) Subtract 01 H from FF H And observe contents of Accumulator and Program
status word
iii) AND 01 H with FF H And observe contents of Accumulator and Program
status word
iv) OR 01 H with FF H And observe contents of Accumulator and Program
status word
v) Ex-or 01 H with FF H And observe contents of Accumulator and Program
status word
vi) Multiply 10 H with 10 H And observe contents of Accumulator and Register
B
vii) Divide 26 H by 02 H And observe contents of Accumulator and Register B
Flowchart :
START
(A)=(A)+8BIT DATA
(A) =RESULT
(PSW)=RESULT
STOP
INPUT: - A=01H
R0=FFH
OUTPUT: - A= H PSW =
INPUT: - A=26H
B=02H
OUTPUT: - A= H
B= H
INPUT: - A=01H
R0=FFH
OUTPUT: -A= H
INPUT: - A=01H
R0=FFH
OUTPUT: - A= H
INPUT: - A=01H
R0=FFH
OUTPUT:-A= H
Aim: - Add 05 data byte in a block , length of the block is at 40H. The block starts at
41H. Place the sum at 30 H.
Objectives: - To Perform addition of data bytes which are present in internal memory
Locations.
Result :- (30H)=0FH
Sum =0
Sum 00H 01H 03H 06H 0AH
+01H + 02H +03H +04H +06H
-------- -------- -------- -------- --------
Sum 01H 03H 07H 0AH 0F H
Flowchart:
START
Count=(40H)
Pointer=41h
Sum=0
Sum =Sum+
(Pointer)
Pointer = Pointer +1
Count = Count-1
Is count No
=0
Yes
(30H)= Sum
End
End
Program:-
Aim: - Find the maximum data byte from a block of 05 data bytes. The length of the
block is at 40 H. The block starts at 41 H. Place maximum data byte at 30 H.
Count = 05
Pointer = 41H
Max = 0
Max>(pointer) Yes
No
Max = (pointer)
Pointer = (Pointer)+1
Count = (Count-1)
No Count = 0
(30H) = Max
end
Program:-
Experiment No.4
Aim: - Transfer a block of 05 data bytes from a source block starting at40H to
destination block starting at 60 H. Length of the block is at 30 H.
start
Count = 05
Ptr1 = 40H
Ptr2 = 60H
(Ptr2) (Ptr1)
Count = Count-1
Yes
Count =
0
No
end
Program:-
Result: - Thus an assembly language program for transfer data bytes in a block
executed successfully.
Experiment No.5
Aim: - Find the no of negative data bytes from a block of 05 data bytes. The length
of the block is at 40H. The block starts at 41H. Place no of negative data bytes at 30 H.
Objectives: - To find number of negative data bytes present in source Memory.
Flowchart:
start
Count = 05H
Nneg = 0
Ptr = 40H
( Ptr) <
0
Yes
Nneg = Nneg+1
Ptr =Ptr +1
Count = (Count-1)
Yes Count =
0
NO
(30H) =Nneg
en
d
Program:-
Memory Hex. Label Assembly Codes Comments
address code
$MOD51
MOV R2,40H ;count =(40H)move
40H to R2
MOV R3,#00H ;nneg =0,move 00H
to R3
MOV R0,#41H ;ptr =41H,move 41H
to R0
UP: MOV A,@R0
CJNEA,#80H, NOTEQUAL ;(ptr)<0
JC POSITIVE ;yes, positive
NOTEQUAL: INC R3 ;nneg =nneg+1
POSITIVE: INC R0 ;ptr =ptr+1
DJNZ R2,UP ;Decrement R2 and
jump if Not Zero
SJMP $
Result: - Thus an assembly language program for find the number of Negative
Data bytes in a block Written and executed successfully.
Experiment No.6
Aim: -Convert Single digit Hex Number at 40H to its ASCII Equivalent at 41H.
Flowchart:
start
Num =(40H)
Yes
Num <
0AH
No
Num = Num+7
No
Num = Num+30H
(41H) = Num
en
d
Program:-
Memory Hex. Label Assembly Codes Comments
address code
$MOD51
MOV A,#40H ;Num =(40H).
CJNE ;Num<0AH
A,#0AH,NOTEQUAL ;yes add A with
NOTEQUAL: JC ASCII0 30H
ADD A,#07 ;Num =Num+07H
ASCII0: ADD A,#30H ;Num=Num+30H
MOV 41H,A ;(41H)=Num
SJMP $
L1:
Result: - Thus an assembly language program for convert single digit Hex
Number to its ASCII equivalent Written and executed successfully.
Experiment No.7
Flowchart:
START
NUM=(40H)
NUM1=NUM
LSD= A
A=NUM1
AND#F0H
SWAP A
MSD
=MULTIPLY A
WITH 10
BINARY=MSD+LSD
Program:- END
Result: - Thus an assembly language program for convert single digit BCD
Number to its Binary equivalent Written and executed successfully.
Experiment No.8
Apparatus required: - RIDE Software/Keil µ ( vision 4), Flash magic, 8051 trainer
kit
Flowchart:
P0.4 = 1
Result: - Thus an assembly language program for Glow LED after every 1ms
Connected to port 0, written and executed successfully.
C Programming
Re sult: Following windows shows that LED connected to P0.4 o f mic rocontroller
8051 toggles after a delay of 100ms .
Experiment No.9
Apparatus required: - Keil Software /RIDE Software, Flash magic, 8051 trainer kit
Flowchart:
start
P0.4 = 1
TMOD = 01H
TH#0 = YY
TL#0 = XX
TR0 = 1
TF0 = 0
No
TF0 =
1
Yes
TR0 = 1
TF0 = 0
P0.4 ~ P0.4
Program:-
$MOD51
BACK: MOV TMOD,#01H ; Initialize timer in
MOV TL0,#6FH MODE 1.
MOV TH0,#0FCH
CLR P0.4 ;clear pin 0.4
ACALL DELAY ;call delay
MOV TL0,#6FH ;move 6FH to TL0
MOV TH0,#0FCH ;move 0FCH to TH0
SETB P0.4 ;set BIT pin 0.4
ACALL DELAY ;call delay
SJMP BACK
DELAY: SETB TR0 ; set on TR0
AGAIN: JNB TF0,AGAIN
CLR TR0 ;clear TR0 flag
CLR TF0 ;clear TF0 flag
RET
END
Result: - Thus an assembly language program for Square waveform of 2ms using
Timer #0 of 8051 written and executed successfully.
Experiment No.10
Aim: - Display 0-9 on seven segment display.
Apparatus required: - RIDE Software/ Keil µ vision4, Flash magic, 8051 trainer kit
Flowchart:
Program:-
Result: Following windows show that micro-controller 8051 sends a BCD no. to port 0
after a delay of 100ms, this data available at port 0 is used to display a BCD no. on seven
segment displays.
EXPERIMENT NO. 11
Flowchart:
Program:-
PIN DESCRIPTION:
INTERFACING DIAGRAM: