ai giup em BTL thiet ke he thong chuong bao truong hoc co dong ho thoi gian su dung LCD
Thông báo
Collapse
No announcement yet.
ae giup em BTL thiet ke he thong chuong bao truong hoc dung 8051 hien thi ra lcd
Collapse
X
-
bạnmuoossn mọi người giúp thì bạn phải cho người ta biết bạn đã có được những gì rồi chư. cách xin của bạn khác gi đi xin chứ. mình nghĩ sẽ ko ai có time để đi làm tất cả cho bạn đâu
thân.!
Nguyên văn bởi icecandylove Xem bài viếtai giup em BTL thiet ke he thong chuong bao truong hoc co dong ho thoi gian su dung LCDNguyễn Huy Biên - 01649 802 694
gmail :
-
#include <sfr51.inc>
;************
org 000h
Ljmp main
scl bit p1.0
sda bit p1.1
mode bit p3.0
tang bit p3.1
giam bit p3.2
hengio bit p3.4
giay bit 28h.0
phut bit 28h.1
gio bit 28h.2
ngay bit 28h.3
thang bit 28h.4
nam bit 28h.5
kiemtra bit 29h.0
tt bit 29h.1
diachi equ 30h
dulieu equ 32h
dulieund equ 33h
dulieunc equ 34h
dulieutd equ 35h
dulieutc equ 36h
dems equ 40h
demp equ 41h
demh equ 42h
demn equ 43h
demt equ 44h
demnd equ 45h
tam2 equ 49h
demndd equ 55h
demndc equ 56h
demncd equ 57h
demncc equ 58h
demp1 equ 59h
demh1 equ 60h
demp1d equ 61h
demp1c equ 62h
demh1d equ 63h
demh1c equ 64h
dem equ 65h
org 030h
;################################################# ###############
;############## Chuong trinh chinh ##########################
;################################################# ###############
main:
clr p3.5
mov p0,#00h
mov dptr,#led7anode
mov dems,#00
mov demp,#00
mov demh,#00
mov demn,#00
mov demt,#00
mov demh1,#00
mov demp1,#00
;################################################# ################
;############# Hien thi led 7 doan ##########################
;################################################# ################
Acall nhanthoigian
clr p3.5
clr tt
clr kiemtra
hienthiled7doan:
Acall nhanthoigian
Acall quetled7doan
baothuc:
jnb kiemtra,kiemtramode
setb p3.5
jb mode,kiemtramode
Acall t50ms
jnb mode,$
clr p3.5
clr tt
clr kiemtra
Ljmp hienthiled7doan
kiemtramode:
jb mode,x
Acall t50ms
jnb mode,$
Ljmp chinhthoigian
x:
jb hengio,kiemtra1
Acall t50ms
jnb hengio,$
Ljmp hengio1
;################################################# ################
;################################################# ################
;############# Bao thuc ##############################
;################################################# ################
kiemtra1:
jnb tt,hienthiled7doan
mov a,r5
cjne a,demh1c,hienthiled7doan
Acall nhanthoigian
Acall quetled7doan
mov a,r4
cjne a,demh1d,hienthiled7doan
acall nhanthoigian
acall quetled7doan
mov a,r3
cjne a,demp1c,hienthiled7doan
Acall nhanthoigian
Acall quetled7doan
mov a,r2
cjne a,demp1d,hienthiled7doan
Acall nhanthoigian
Acall quetled7doan
setb kiemtra
Ljmp hienthiled7doan
;################################################# ################
;################################################# ################
;############# Hen gio ##############################
;################################################# ################
hengio1:
modeh1:
mov tam2,demh1
Acall chuyensangbcd
mov a,53h
movc a,@a+dptr
mov p2,a
setb p0.4
Acall t50ms
clr p0.4
mov a,52h
movc a,@a+dptr
mov p2,a
setb p0.5
Acall t50ms
clr p0.5
kiemtratangh1:
jb tang,kiemtragiamh1
Acall t50ms
jnb tang,$
inc demh1
mov a,demh1
cjne a,#24,modeh1
mov demh1,#00
Ljmp modeh1
kiemtragiamh1:
jb giam,kiemtramodep1
Acall t50ms
jnb giam,$
dec demh1
mov a,demh1
cjne a,#0ffh,modeh1
mov demh1,#23
Ljmp modeh1
kiemtramodep1:
jb hengio,modeh1
Acall t50ms
jnb hengio,$
modep1:
mov tam2,demh1
Acall chuyensangbcd
mov a,53h
movc a,@a+dptr
mov p2,a
setb p0.4
Acall t50ms
clr p0.4
mov a,52h
movc a,@a+dptr
mov p2,a
setb p0.5
Acall t50ms
clr p0.5
mov tam2,demp1
Acall chuyensangbcd
mov a,53h
movc a,@a+dptr
mov p2,a
setb p0.2
Acall t50ms
clr p0.2
mov a,52h
movc a,@a+dptr
mov p2,a
setb p0.3
Acall t50ms
clr p0.3
kiemtratangp1:
jb tang,kiemtragiamp1
Acall t50ms
jnb tang,$
inc demp1
mov a,demp1
cjne a,#60,modep1
mov demp1,#00
Ljmp modep1
kiemtragiamp1:
jb giam,kiemtramodes1
Acall t50ms
jnb giam,$
dec demp1
mov a,demp1
cjne a,#0ffh,modep1
mov demp1,#59
Ljmp modep1
kiemtramodes1:
jb hengio,modep1
Acall t50ms
jnb hengio,$
mov tam2,demp1
Acall chuyensangbcd
mov r1,#52h
mov r0,#53h
xchd a,@r1
swap a
xchd a,@r0
mov dulieu,a
mov diachi,#0ah
Acall truyen
mov tam2,demh1
Acall chuyensangbcd
mov r1,#52h
mov r0,#53h
xchd a,@r1
swap a
xchd a,@r0
mov dulieu,a
mov diachi,#0bh
Acall truyen
setb tt
Ljmp hienthiled7doan
;################################################# ################
;################################################# ################
;############# Chinh thoi gian ##############################
;################################################# ################
chinhthoigian:
mov 28h,#00
mov diachi,#00h
Acall nhan
mov tam2,dulieu
Acall chuyenbcdsanghex
mov dems,tam2
mov diachi,#01h
Acall nhan
mov tam2,dulieu
Acall chuyenbcdsanghex
mov demp,tam2
mov diachi,#02h
Acall nhan
mov tam2,dulieu
Acall chuyenbcdsanghex
mov demh,tam2
mov diachi,#04h
Acall nhan
mov tam2,dulieu
Acall chuyenbcdsanghex
mov demn,tam2
mov diachi,#05h
Acall nhan
mov tam2,dulieu
Acall chuyenbcdsanghex
mov demt,tam2
mov diachi,#06h
Acall nhan
mov tam2,dulieu
Acall chuyenbcdsanghex
mov demnd,tam2
mov dem,#020
modeh:
Acall quetled7doanchoptat
dec dem
mov a,dem
cjne a,#00,kiemtratangh
mov dem,#020
cpl gio
kiemtratangh:
jb tang,kiemtragiamh
Acall t50ms
jnb tang,$
inc demh
mov a,demh
cjne a,#24,modeh
mov demh,#00
Ljmp modeh
kiemtragiamh:
jb giam,kiemtramodep
jnb giam,$
dec demh
mov a,demh
cjne a,#0ffh,modeh
mov demh,#23
Ljmp modeh
kiemtramodep:
jb mode,modeh
Acall t50ms
jnb mode,$
mov 28h,#00
modep:
Acall quetled7doanchoptat
dec dem
mov a,dem
cjne a,#00,kiemtratangp
mov dem,#020
cpl phut
kiemtratangp:
jb tang,kiemtragiamp
Acall t50ms
jnb tang,$
inc demp
mov a,demp
cjne a,#60,modep
mov demp,#00
Ljmp modep
kiemtragiamp:
jb giam,kiemtramodes
Acall t50ms
jnb giam,$
dec demp
mov a,demp
cjne a,#0ffh,modep
mov demp,#59
Ljmp modep
kiemtramodes:
jb mode,modep
Acall t50ms
jnb mode,$
mov 28h,#00
modes:
Acall quetled7doanchoptat
dec dem
mov a,dem
cjne a,#00,kiemtratangs
mov dem,#020
cpl giay
kiemtratangs:
jb tang,kiemtragiams
Acall t50ms
jnb tang,$
inc dems
mov a,dems
cjne a,#60,modes
mov dems,#00
Ljmp modes
kiemtragiams:
jb giam,kiemtramoden
Acall t50ms
jnb giam,$
dec dems
mov a,dems
cjne a,#0ffh,modes
mov dems,#59
Ljmp modes
kiemtramoden:
jb mode,modes
Acall t50ms
jnb mode,$
mov 28h,#00
moden:
Acall quetled7doanchoptat
dec dem
mov a,dem
cjne a,#00,kiemtratangn
mov dem,#020
cpl ngay
kiemtratangn:
jb tang,kiemtragiamn
Acall t50ms
jnb tang,$
inc demn
mov a,demn
cjne a,#32,moden
mov demn,#00
Ljmp moden
kiemtragiamn:
jb giam,kiemtramodet
Acall t50ms
jnb giam,$
dec demn
mov a,demn
cjne a,#0ffh,moden
mov demn,#31
Ljmp moden
kiemtramodet:
jb mode,moden
Acall t50ms
jnb mode,$
mov 28h,#00
modet:
Acall quetled7doanchoptat
dec dem
mov a,dem
cjne a,#00,kiemtratangt
mov dem,#020
cpl thang
kiemtratangt:
jb tang,kiemtragiamt
Acall t50ms
jnb tang,$
inc demt
mov a,demt
cjne a,#13,modet
mov demt,#01
Ljmp modet
kiemtragiamt:
jb giam,kiemtramodenam
Acall t50ms
jnb giam,$
dec demt
mov a,demt
cjne a,#0ffh,modet
mov demt,#12
Ljmp modet
kiemtramodenam:
jb mode,modet
Acall t50ms
jnb mode,$
mov 28h,#00
modenam:
Acall quetled7doanchoptat
dec dem
mov a,dem
cjne a,#00,kiemtratangnam
mov dem,#020
cpl nam
kiemtratangnam:
jb tang,kiemtragiamnam
Acall t50ms
jnb tang,$
inc demnd
mov a,demnd
cjne a,#100,modenam
mov demnd,#00
Ljmp modenam
kiemtragiamnam:
jb giam,kiemtramodethoat
Acall t50ms
jnb giam,$
dec demnd
mov a,demnd
cjne a,#0ffh,modenam
mov demnd,#099
Ljmp modenam
kiemtramodethoat:
jb mode,modenam
Acall t50ms
jnb mode,$
Acall guithoigian
Ljmp hienthiled7doan
;################################################# ################
;################################################# ################
;############# Nhan thoi gian ##############################
;################################################# ################
nhanthoigian:
mov diachi,#00h
Acall nhan
mov tam2,dulieu
Acall chuyensanghex
mov r0,53h
mov r1,52h
mov diachi,#01h
Acall nhan
mov tam2,dulieu
Acall chuyensanghex
mov r2,53h
mov r3,52h
mov diachi,#02h
Acall nhan
mov tam2,dulieu
Acall chuyensanghex
mov r4,53h
mov r5,52h
mov diachi,#04h
Acall nhan
mov tam2,dulieu
Acall chuyensanghex
mov dulieund,53h
mov dulieunc,52h
mov diachi,#05h
Acall nhan
mov tam2,dulieu
Acall chuyensanghex
mov dulieutd,53h
mov dulieutc,52h
mov diachi,#06h
Acall nhan
mov tam2,dulieu
Acall chuyensanghex
mov demndd,53h
mov demndc,52h
jnb tt,x2
mov diachi,#0ah
Acall nhan
mov tam2,dulieu
Acall chuyensanghex
mov demp1d,53h
mov demp1c,52h
mov diachi,#0bh
Acall nhan
mov tam2,dulieu
Acall chuyensanghex
mov demh1d,53h
mov demh1c,52h
ret
;################################################# ################
;################################################# ################
;############# Gui thoi gian ###############################
;################################################# ################
guithoigian:
mov tam2,dems
Acall chuyensangbcd
mov r1,#52h
mov r0,#53h
xchd a,@r1
swap a
xchd a,@r0
mov dulieu,a
mov diachi,#00h
Acall truyen
mov tam2,demp
Acall chuyensangbcd
mov r1,#52h
mov r0,#53h
xchd a,@r1
swap a
xchd a,@r0
mov dulieu,a
mov diachi,#01h
Acall truyen
mov tam2,demh
Acall chuyensangbcd
mov r1,#52h
mov r0,#53h
xchd a,@r1
swap a
xchd a,@r0
mov dulieu,a
mov diachi,#02h
Acall truyen
mov tam2,demn
Acall chuyensangbcd
mov r1,#52h
mov r0,#53h
xchd a,@r1
swap a
xchd a,@r0
mov dulieu,a
mov diachi,#04h
Acall truyen
mov tam2,demt
Acall chuyensangbcd
mov r1,#52h
mov r0,#53h
xchd a,@r1
swap a
xchd a,@r0
mov dulieu,a
mov diachi,#05h
Acall truyen
mov tam2,demnd
Acall chuyensangbcd
mov r1,#52h
mov r0,#53h
xchd a,@r1
swap a
xchd a,@r0
mov dulieu,a
mov diachi,#06h
Acall truyen
ret
;################################################# ################
;################################################# ################
;############# Truyen I2C ###################################
;################################################# ################
;################################################# ################
;################################################# ################
;############# Nhan du lieu #################################
;################################################# ################
nhan:
Acall start
mov a,#0d0h
Acall send
setb sda
setb scl
jb sda,nhan
clr scl
mov a,diachi
Acall send
setb sda
setb scl
jb sda,nhan
clr scl
Acall start
mov a,#0d1h
Acall send
setb sda
setb scl
jb sda,nhan
clr scl
Acall receive
Acall stop
ret
receive:
mov r7,#08h
lap_receive:
setb scl
mov c,sda
clr scl
rlc a
djnz r7,lap_receive
mov dulieu,a
setb scl
clr sda
clr scl
ret
;################################################# ################
;################################################# ################
;############# Truyen du lieu ###############################
;################################################# ################
truyen:
Acall start
mov a,#0d0h
Acall send
setb sda
setb scl
jb sda,truyen
clr scl
mov a,diachi
Acall send
setb sda
setb scl
jb sda,truyen
clr scl
mov a,dulieu
Acall send
setb sda
setb scl
jb sda,truyen
clr scl
Acall stop
ret
send:
mov r7,#08h
lap_send:
rlc a
mov sda,c
setb scl
clr scl
djnz r7,lap_send
ret
;################################################# ################
;################################################# ################
;############# Start I2C ####################################
;################################################# ################
start:
setb sda
setb scl
nop
nop
clr sda
nop
nop
clr scl
nop
ret
;################################################# ################
;################################################# ################
;############# Stop I2C #####################################
;################################################# ################
stop:
clr sda
nop
nop
setb scl
nop
nop
setb sda
ret
;################################################# ################
;################################################# ################
;############# Quet led 7 doan chop tat #####################
;################################################# ################
quetled7doanchoptat:
jb gio,phut1
mov tam2,demh
Acall chuyensangbcd
mov a,53h
movc a,@a+dptr
mov p2,a
setb p0.4
Acall t50ms
clr p0.4
mov a,52h
movc a,@a+dptr
mov p2,a
setb p0.5
Acall t50ms
clr p0.5
phut1:
jb phut,giay1
mov tam2,demp
Acall chuyensangbcd
mov a,53h
movc a,@a+dptr
mov p2,a
setb p0.2
Acall t50ms
clr p0.2
mov a,52h
movc a,@a+dptr
mov p2,a
setb p0.3
Acall t50ms
clr p0.3
giay1:
jb giay,ngay1
mov tam2,dems
Acall chuyensangbcd
mov a,53h
movc a,@a+dptr
mov p2,a
setb p0.0
Acall t50ms
clr p0.0
mov a,52h
movc a,@a+dptr
mov p2,a
setb p0.1
Acall t50ms
clr p0.1
ngay1:
jb ngay,thang1
mov tam2,demn
Acall chuyensangbcd
mov a,53h
movc a,@a+dptr
mov p2,a
setb p0.7
Acall t50ms
clr p0.7
mov a,52h
movc a,@a+dptr
mov p2,a
setb p0.6
Acall t50ms
clr p0.6
thang1:
jb thang,nam1
mov tam2,demt
Acall chuyensangbcd
mov a,53h
movc a,@a+dptr
mov p2,a
setb p1.3
Acall t50ms
clr p1.3
mov a,52h
movc a,@a+dptr
mov p2,a
setb p1.2
Acall t50ms
clr p1.2
nam1:
jb nam,thoatquet
mov tam2,demnd
Acall chuyensangbcd
mov a,53h
movc a,@a+dptr
mov p2,a
setb p1.7
Acall t50ms
clr p1.7
mov a,52h
movc a,@a+dptr
mov p2,a
setb p1.6
Acall t50ms
clr p1.6
mov a,#00h
movc a,@a+dptr
mov p2,a
setb p1.5
Acall t50ms
clr p1.5
mov a,#02h
movc a,@a+dptr
mov p2,a
setb p1.4
Acall t50ms
clr p1.4
ret
thoatquet:
ret
;################################################# ################
;################################################# ################
;############# Quet led 7 doan ##############################
;################################################# ################
quetled7doan:
mov a,r0
movc a,@a+dptr
mov p2,a
setb p0.0
Acall t50ms
clr p0.0
mov a,r1
movc a,@a+dptr
mov p2,a
setb p0.1
Acall t50ms
clr p0.1
mov a,r2
movc a,@a+dptr
mov p2,a
setb p0.2
Acall t50ms
clr p0.2
mov a,r3
movc a,@a+dptr
mov p2,a
setb p0.3
Acall t50ms
clr p0.3
mov a,r4
movc a,@a+dptr
mov p2,a
setb p0.4
Acall t50ms
clr p0.4
mov a,r5
movc a,@a+dptr
mov p2,a
setb p0.5
Acall t50ms
clr p0.5
mov a,dulieund
movc a,@a+dptr
mov p2,a
setb p0.7
Acall t50ms
clr p0.7
mov a,dulieunc
movc a,@a+dptr
mov p2,a
setb p0.6
Acall t50ms
clr p0.6
mov a,dulieutd
movc a,@a+dptr
mov p2,a
setb p1.3
Acall t50ms
clr p1.3
mov a,dulieutc
movc a,@a+dptr
mov p2,a
setb p1.2
Acall t50ms
clr p1.2
mov a,demndd
movc a,@a+dptr
mov p2,a
setb p1.7
Acall t50ms
clr p1.7
mov a,demndc
movc a,@a+dptr
mov p2,a
setb p1.6
Acall t50ms
clr p1.6
mov a,#00h
movc a,@a+dptr
mov p2,a
setb p1.5
Acall t50ms
clr p1.5
mov a,#02h
movc a,@a+dptr
mov p2,a
setb p1.4
Acall t50ms
clr p1.4
ret
;################################################# #######################
;################################################# #######################
;############################# Thoi gian quet led #######################
;################################################# #######################
t50ms:
push 30h
push 31h
mov 30h,#4
mov 31h,#1
lap:
djnz 31h,$
djnz 30h,lap
pop 31h
pop 30h
ret
;################################################# ########################
;################################################# ########################
;########################## Chuyen BCD sang HEX ##########################
;################################################# ########################
chuyenbcdsanghex:
mov a,tam2
anl a,#00001111b
mov 53h,a
mov a,tam2
anl a,#11110000b
swap a
mov 52h,a
mov b,52h
mov a,#0ah
mul ab
add a,53h
mov tam2,a
ret
;################################################# ########################
;################################################# ########################
;########################## Chuyen sang HEX ##############################
;################################################# ########################
chuyensanghex:
mov a,tam2
anl a,#00001111b
mov 53h,a
mov a,tam2
anl a,#11110000b
swap a
mov 52h,a
ret
;################################################# ########################
;################################################# ########################
;########################## Chuyen sang BCD ##############################
;################################################# ########################
chuyensangbcd:
tam equ 51h
tam1 equ 50h
mov tam,tam2
mov a,tam
mov b,#10
div ab
mov 52h,a
mov b,#10
mul ab
mov tam1,a
mov a,tam
clr c
subb a,tam1
mov 53h,a
ret
;################################################# ############################
;################################################# ############################
;###################### Du lieu quet led 7 doan ##############################
;################################################# ############################
led7anode:
db 01000000b,01111001b,00100100b,00110000b,00011001b, 00010010b,00000010b,01111000b,00000000b,00010000b
;################################################# ############################
end
ban nao biet sua code tren va dua hien thi ra LCD giup minh voi
Comment
Bài viết mới nhất
Collapse
-
Trả lời cho Hỏi cách điều chế xungbởi thetungBạn cho qua cái Tờ ri gơ Sờ mít ấy ......
-
Channel: Kỹ thuật điện tử tương tự
16-12-2024, 11:26 -
-
Trả lời cho Hỏi cách điều chế xungbởi nguyendinhvanCó gì mà khó ?
Răn cưa vuông đây
...-
Channel: Kỹ thuật điện tử tương tự
15-12-2024, 23:36 -
-
Trả lời cho hỏi về tụ điệnbởi ndp62Chữ " VENT" không phải là tên hãng sx tụ đâu ,vó thế là 1 ký hiệu liên quan tụ lowesr ?
-
Channel: Điện thanh
15-12-2024, 18:24 -
-
Trả lời cho Thắc mắc về nguồn tổ ong 12vbởi bqvietTrừ trường hợp công suất (rất) thấp, hầu như tất cả các loại nguồn xung thông thường đều có tụ nhỏ 1 - 10nF nối giữa sơ cấp và thứ cấp, để thoát nhiễu và để chống hiện tượng tương tự tĩnh điện. Vụ này đã thảo luận vài...
-
Channel: Điện tử dành cho người mới bắt đầu
14-12-2024, 22:02 -
-
Trả lời cho Thắc mắc về nguồn tổ ong 12vbởi namlangnhoE thử 3 cái nguồn nó đều giống nhau. Nên e làm tiếp địa luôn.
-
Channel: Điện tử dành cho người mới bắt đầu
14-12-2024, 19:58 -
-
Trả lời cho Thắc mắc về nguồn tổ ong 12vbởi mèomướpDạ chú sắm con át chống giật và thay nguồn tổ ong khác cho an toàn ạ. Đa phần nguồn xung đều xả nhiễu của bên thứ cấp về điện lưới qua 1 con tụ nên cảm giác tê sẽ khó xác định rõ ràng là do rò điện hay là nó vốn vậy...
-
Channel: Điện tử dành cho người mới bắt đầu
14-12-2024, 18:51 -
-
bởi namlangnhoXin chào mọi người. E có sử dụng 1 cục nguồn tổ ong 12v-30A chạy đèn led xe trà sữa. Mà thợ thi công bị rò điện nên điện rò ra khung xe. E dùng đồng hồ đo điện ở khung xe và cả output thì thấy có dòng điện xoay chiều hơn 100v. Nên chạm...
-
Channel: Điện tử dành cho người mới bắt đầu
14-12-2024, 00:12 -
-
bởi Manh.n.trCác bác cho em hỏi cách điều chế xung răng cưa sang xung vuông với ạ. Em đang thấy khó ạ...
-
Channel: Kỹ thuật điện tử tương tự
13-12-2024, 20:46 -
-
Trả lời cho hỏi về thiết kế mạch tuần tự trên proteusbởi Hatruong1309
-
Channel: Hỗ trợ học tập
12-12-2024, 00:33 -
-
bởi Hatruong1309Cho e hỏi là phần chân X thì nối cái j thì mạch mới chạy được ạ và kiểm tra đúng sai kiểu j ạ
Đề bài thiết kế mạch dãy đồng bộ nhận biết dãy tín hiệu vào ở dạng nhị phân được đưa liên tiếp ở đầu vào X và được đồng...-
Channel: Hỗ trợ học tập
12-12-2024, 00:33 -
Comment