Professional Documents
Culture Documents
Name
Reg.No
Center
: S.A.D.L. Janaka
: 50564695
: Colombo
Aim:
Objectives:
Familiar with the use of the 8051 interrupt service routing timer and counter
available in 8051.
Familiar with the use of LCD display on the 8051 development board.
Writing ASM program for interrupt service routings, software and timer delay.
Identify to connect SRF 04 to 8051 microcontroller.
Identify SRF05 state using 8051 microcontroller.
Equipments Used:
Note pad
ASM-51 Assembler
8052 Simulator
Terminal Emulator
Procedure:
Connect the PC to the AES-51 Board using serial ribbon cable and
power up the PC
Write the source code (ALP) in Notepad and save it as ASM (File
name .ASM) file
Use ASM-51 Assembler to produced HEX file (Which contains machine
codes in hex format plus address) and LST file (Which contains detail records
of both the source file and the hex machine code)
Using LST (List) file check whether is there any errors in the program
ie data 0a8h
tmod data 089h
th1 data 08dh
b DATA 0F0H
tl1 data 08bh
th0 data 08ch
tl0 data 08ah
tr1 bit 08eh
tf1 bit 08fh
tr0 bit 08ch
p1_4 bit 094h
p3_2 bit 0b2h
dph data 83h
dpl data 82h
19
20
21
22
ljmp isr_ex
ljmp isr_ti
25
org 7000h
28
main:
30
7000 75A889
interupt0
32
33
7003 D2B2
7005 1149
7007 C2B2
37
38
7009 114E
700B 80F3
41
42
43
700D
700D 758909
timer0 16 bit timer
7010 80FE
get interupt
47
48
49
50
7012 C28C
52
7014 858C83
7017 E583
7019 75F03A
701C 84
56
701D F9
701E 858A82
31
34
35
36
setb p3_2
acall Tigger_Dellay
clr p3_2
39
40
acall Repeat_tigger
sjmp main
44
45
isr_ex:
mov tmod,#00001001b
46
here:
51
sjmp here
clr tr0
53
54
55
mov dph,Th0
mov a,dph
mov b,#58
div ab
57
mov R1,a
58
mov dpl,tl0
7021 E582
59
mov a,dpl
7023 75F03A
60
mov b,#58
7026 84
61
div ab
7027 FA
62
mov R2,a
63
7028 8036
64
SJMP DISPALY
65
702A 32
66
reti
67
68 ;***** generate 30 ms timer dellay*****
;select
;stop timer0
702B
69 isr_ti:
702B 758910
70
mov tmod,#00010000b
;select
timer1 16 bittimer mode
702E 758D8A
71
mov th1,#8ah
7031 758BD0
72
mov tl1,#0d0h
7034 D28E
73
setb tr1
;start timer1
7036 1157
74
acall Echo_Dellay
7038 20B2FD
75
jb p3_2,$
703B 8006
76
sjmp no_object
703D 308FFC
77
jnb tf1,$-1
7040 C28E
78
clr tr1
79
80
;stop timer1
7042 32
81
reti
82
7043
83 no_object:
7043 C294
84
clr p1_4
7045 114E
85
acall Repeat_tigger
7047 80FA
86
sjmp no_object
87
7049
88 Tigger_Dellay:
;10us dellay
89
7049 7804
90
mov R0,#4
704B D8FC
91
djnz R0,$-2
704D 22
92
ret
93
704E
94 Repeat_tigger:
; 50ms dellay
95
704E 7962
96
mov R1,#98
7050 7A00
97 D1:
mov R2,#0
7052 DAFE
98 D:
djnz R2,D
7054 D9FA
99
djnz R1,D1
7056 22
100
ret
101
7057
102 Echo_Dellay:
;1ms dellay
103
7057 7B02
104
mov R3,#2
7059 7C00
105 D2:
mov R4,#0
705B DCFB
106
djnz R4,$-3
705D DBFA
107
djnz R3,D2
705F 22
108
ret
109
7060
110 DISPALY:
111
7060
7063
7064
7067
7068
758300
E9
B58313
93
F521
706A 124104
118
706D 758300
7070 EA
7071 B58306
7074 93
7075 F521
7077 124104
125
707A A3
127
7100
7100 30313233
7104 34353637
7108 3839
130
131
132
133 end
134
135
112
113
114
115
116
117
119
120
121
122
123
124
126
do:
128
129
mov
dph,#7100h
mov
a,r1
cjne a,dph,do
movc a,@a+dptr
mov
21h,a
call
4104h
mov
dph,#7100h
mov
a,r2
cjne a,dph,do
movc a,@a+dptr
mov
21h,a
call 4104h
inc dptr
org
db
7100h
'0123456789'
B. . . . . . . . . . . . . . . . D ADDR 00F0H
D. . . . . . . . . . . . . . . . C ADDR 7052H
D1 . . . . . . . . . . . . . . . C ADDR 7050H
D2 . . . . . . . . . . . . . . . C ADDR 7059H
DISPALY. . . . . . . . . . . . . C ADDR 7060H
DO . . . . . . . . . . . . . . . C ADDR 707AH
DPH. . . . . . . . . . . . . . . D ADDR 0083H
DPL. . . . . . . . . . . . . . . D ADDR 0082H
ECHO_DELLAY. . . . . . . . . . . C ADDR 7057H
HERE . . . . . . . . . . . . . . C ADDR 7010H
IE . . . . . . . . . . . . . . . D ADDR 00A8H
ISR_EX . . . . . . . . . . . . . C ADDR 700DH