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 xin sơ đồ tivi các loạibởi Trân thànhCần các Bạn giúp sơ đồ Lcd Samsung UA40JU6400 và UA43ku6500k. Xin cảm ơn!...
-
Channel: Điện tử truyền hình
Hôm qua, 16:07 -
-
Trả lời cho Hỏi xin sơ đồ tivi các loạibởi Trân thànhCần các Bạn giúp sơ đồ Lcd Samsung UA40JU6400 và UA43ku6500k. Xin cảm ơn!...
-
Channel: Điện tử truyền hình
Hôm qua, 16:01 -
-
bởi chinhnguyen9Hoạt động của thế hệ mạch cân bằng trước đây dựa trên nguyên lý so áp giữa 2 string liền kề. Hoạt động cân bằng chỉ kích hoạt khi sự chênh lệch vượt ngưỡng 100mV và ngưng hoạt động khi mức chênh lệch giảm xuống còn 30mV. Bản...
-
Channel: Điện tử dành cho người mới bắt đầu
27-04-2024, 05:07 -
-
bởi chinhnguyen9Xem hình minh họa có phần thuyết minh bên trong tiện việc quan sát và đọc thuyết minh. Khi G1 high dòng điện chạy theo các đường màu đen khi G2 high dòng điện chạy theo các đường màu nâu đỏ.
Bổ sung một tính chất củng cố cho tên gọi tụ bay: Trong mạch đề cập chỉ...-
Channel: Điện tử dành cho người mới bắt đầu
26-04-2024, 21:02 -
-
bởi chinhnguyen9Sản phẩm này ghi version 2.0 01-2024 MADE IN CHINA nhưng không thấy thương hiệu hình 1
Do 8 chân G của 8 mosfet được đấu song song thành 2 nhóm nên có cùng biên độ xung kích 12V. Nhưng Q1 và Q2 nằm cuối dãy, chân S cùa chúng có điện áp DC cao đến...-
Channel: Điện tử dành cho người mới bắt đầu
26-04-2024, 20:37 -
-
bởi xuanthiettivi em bị mất remote lỡ vào chế độ usb giờ không chọn lại source được. ai có file nạp cho em xin với ạ. Model 32HD957T2
-
Channel: Điện tử truyền hình
26-04-2024, 10:53 -
-
Trả lời cho Giải thích nôm na từ "tụ bay"bởi chinhnguyen9Đa tạ lời cảm ơn của bạn. Mến!
-
Channel: Hướng dẫn sử dụng diễn đàn
26-04-2024, 05:06 -
-
Trả lời cho Xin tư vấn về mạch cầu H cho inverter 1000wbởi thebinhzChắc là không được đâu bạn ơi
Quán ăn Vĩnh Yên-
Channel: Điện tử công suất
25-04-2024, 21:56 -
-
Trả lời cho Giải thích nôm na từ "tụ bay"bởi thebinhzCảm ơn bạn nhiều nha
Nhà hàng Vĩnh Yên-
Channel: Hướng dẫn sử dụng diễn đàn
25-04-2024, 21:50 -
-
bởi chinhnguyen9Vai viết này đã được chuyển sang chuyên mục phù hợp....
-
Channel: Hướng dẫn sử dụng diễn đàn
25-04-2024, 08:29 -
Comment