Cái này mình làm đã 1 năm rồi thấy chạy ổn định nên post cho mọi người coi. Thỉnh thoảng phải chỉnh vì mua phải con 12887 hàng cũ bung máy nên có lỗi tý ty 1 nét trên con 7 đoạn phần tháng bị cháy do mình thử với 12v ko qua trở nên nó bị vậy đó, ko kiếm dc con nào to tương tự để thay nên cứ để đó.
Mạch nguyên bản của tác giả
Mình vẽ lại thì bỏ con IC cho điểu khiển từ xa, thay lại phần đệm tran......
Code nguyên bản của tác giả
Do lười vè SCh nên chỉ vẽ pcb , sch coi lại của tác giả nhé, đây là PCB mạch điều khiển có chỉnh sửa cho phù hợp:
Một con 89 góc phải phía dưới định làm mạch nhạc bài "A time for us" mỗi khi đổ chuông, nhưng thất bại nên để trống đó!
Toàn làm rời và kết nối các module lại với nhau.
Module giờ phút giây
Module ngày tháng
Module năm
Mình dùng mấy con led 7 thanh to to, 5v ko sáng dc nên chơi điện 12V và qua ít trở 100R hạn dòng, các khóa đóng mở cho led sáng dc ghép darlington
Code của mình khi thay đổi, sửa chữa đâu đó, và bớt phần ko cần thiết ( cài giờ đổ chuông) để phù hợp!
P/S: Cái này ko phải do mình viết ra, mình chỉ vẽ lại phần cứng, sửa code cho phù hợp với phần cứng mình thiết kế mà thôi (chủ yếu là sửa phần nút bấm với phần hiển thị). Các bạn có thể tham khảo file gốc để thay đổi phù hợp hơn
Thân
Mạch nguyên bản của tác giả
Mình vẽ lại thì bỏ con IC cho điểu khiển từ xa, thay lại phần đệm tran......
Code nguyên bản của tác giả
Code:
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ; P0 data led, P1 quét led ngày tháng năm,P2 quét led giờ phút giây và thứ ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx dwn bit p3.3 up bit p3.1 mode bit p3.0 mode1 bit p3.5 bell bit p3.4 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx org 000h jmp main org 003h jmp ngat_n0 main: mov r3,#0 lcall khoitaodallass lcall delay mov ie,#81h setb it0 tu_dau1: setb bell mov r2,#0 tu_dau: lcall doc_data lcall hex_bcd lcall bcd_7doan lcall hien_thi jb mode,adj jb mode1,adj_alr cjne r2,#0,ngat_bell sjmp tu_dau ngat_bell: lcall doc_data mov a,4fh add a,#2 cjne a,#60,kt_c23 kt_c23: jc tiep mov 4fh,10h jmp tu_dau tiep: cjne a,10h,tu_dau mov 4fh,10h cpl bell djnz 4eh,tu_dau mov r0,#0ch movx a,@r0 jmp tu_dau1 adj_alr: jmp set_alr ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx adj: lcall hien_thi jb mode,adj mov 78h,#15 adj1: lcall hien_thi jb mode,adj djnz 78h,adj1 inc r3 cjne r3,#08,loop mov r3,#0 ljmp tu_dau ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx loop: mov 67h,#10 loop3: mov 66h,#0afh loop1: lcall doc_data lcall hex_bcd lcall bcd_7doan lcall hien_thi jb up,tang jb dwn,giam1 jb mode,adj djnz 66h,loop1 cjne r3,#1,tatphut mov 34h,#0ffh mov 35h,#0ffh sjmp tat tatphut: cjne r3,#02,tatgio mov 32h,#0ffh mov 33h,#0ffh sjmp tat tatgio: cjne r3,#03,tatthu mov 30h,#0ffh mov 31h,#0ffh sjmp tat tatthu: cjne r3,#04,tatngay mov 36h,#0ffh sjmp tat tatngay: cjne r3,#05,tatthang mov 37h,#0ffh mov 38h,#0ffh sjmp tat tatthang: cjne r3,#06,tatnam mov 39h,#0ffh mov 3ah,#0ffh sjmp tat tatnam: mov 3eh,#0ffh mov 3dh,#0ffh tat: mov 66h,#0afh loop2: lcall hien_thi jb up,tang jb dwn,giam1 jb mode,adj2 djnz 66h,loop2 djnz 67h,loop3 mov r3,#0 ljmp tu_dau adj2: ljmp adj ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx giam1: ljmp giam ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx tang: mov 78h,#100 tang1: lcall hien_thi djnz 78h,tang1 cjne r3,#01h,ss1 mov r0,#04h movx a,@r0 inc a cjne a,#24,z1 mov a,#0 z1: movx @r0,a jmp loop ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss1: cjne r3,#02h,ss2 mov r0,#02h movx a,@r0 inc a cjne a,#60,z1 mov a,#0 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss2: cjne r3,#03,ss3 mov r0,#0h movx a,@r0 inc a cjne a,#060,z1 mov a,#0 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss3: cjne r3,#04,ss4 mov r0,#06h movx a,@r0 inc a cjne a,#08,z1 mov a,#01 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss4: cjne r3,#05,ss5 mov r0,#07h movx a,@r0 inc a cjne a,#032,z1 mov a,#00 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss5: cjne r3,#06,ss6 mov r0,#08h movx a,@r0 inc a cjne a,#013,z1 mov a,#01 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss6: mov r0,#09h movx a,@r0 inc a cjne a,#100,z1 mov a,#00 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx giam: mov 78h,#100 giam11: lcall hien_thi djnz 78h,giam11 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx cjne r3,#01h,sss1 mov r0,#04 movx a,@r0 dec a cjne a,#0ffh,zz1 mov a,#23 zz1: movx @r0,a jmp loop ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss1: cjne r3,#02h,sss2 mov r0,#02h movx a,@r0 dec a cjne a,#0ffh,zz1 mov a,#59 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss2: cjne r3,#03h,sss3 mov r0,#0h movx a,@r0 dec a cjne a,#0ffh,zz1 mov a,#59 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss3: cjne r3,#04h,sss4 mov r0,#06h movx a,@r0 dec a cjne a,#0h,zz1 mov a,#7 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss4: cjne r3,#05h,sss5 mov r0,#07h movx a,@r0 dec a cjne a,#0ffh,zz1 mov a,#31 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss5: cjne r3,#06,sss6 mov r0,#08h movx a,@r0 dec a cjne a,#01h,zz1 mov a,#12 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss6: mov r0,#09 movx a,@r0 dec a cjne a,#0ffh,zz1 mov a,#99 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ; doan ct cai dat bao thuc set_alr: lcall hien_thi_alr jb mode1,set_alr set_a: inc r3 cjne r3,#4,wait mov r3,#0 ljmp tu_dau wait: mov 67h,#10 wait3: mov 66h,#0ffh lcall doc_data_alr lcall hex_bcd lcall bcd_7doan wait1: lcall hien_thi_alr jb up,tang_alr jb dwn,giam_alr jb mode1,set_alr djnz 66h,wait1 cjne r3,#1,tatphut_alr mov 35h,#0ffh mov 34h,#0ffh sjmp tat_alr tatphut_alr: cjne r3,#2,tatgiay_alr mov 32h,#0ffh mov 33h,#0ffh sjmp tat_alr tatgiay_alr: mov 31h,#0ffh mov 30h,#0ffh tat_alr: mov 66h,#0ffh wait2: lcall hien_thi_alr jb up,tang_alr jb dwn,giam_alr jb mode1,set_alr djnz 66h,wait2 djnz 67h,wait3 mov r3,#0 ljmp tu_dau ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx tang_alr: mov 78h,#200 tang1_alr: lcall hien_thi_alr djnz 78h,tang1_alr waitx3: cjne r3,#01h,ss_alr1 mov r0,#05h movx a,@r0 inc a cjne a,#24,z_alr1 mov a,#0 z_alr1: movx @r0,a jmp wait ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss_alr1: cjne r3,#2,ss_alr2 mov r0,#03h movx a,@r0 inc a cjne a,#60,z_alr1 mov a,#0 jmp z_alr1 ss_alr2: mov r0,#01h movx a,@r0 inc a cjne a,#60,z_alr1 mov a,#0 jmp z_alr1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx giam_alr: mov 78h,#200 giam_alr11: lcall hien_thi_alr djnz 78h,giam_alr11 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx waity3: cjne r3,#01h,sss_alr1 mov r0,#5 movx a,@r0 dec a cjne a,#0ffh,zz_alr1 mov a,#24 zz_alr1: movx @r0,a jmp wait ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss_alr1: cjne r3,#2,sss_alr2 mov r0,#03h movx a,@r0 dec a cjne a,#0ffh,zz_alr1 mov a,#59 jmp zz_alr1 sss_alr2: mov r0,#01h movx a,@r0 dec a cjne a,#0ffh,zz_alr1 mov a,#59 jmp zz_alr1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx khoitaodallass: mov r0,#0bh mov a,#026h movx @r0,a ;cho phep chinh cai dat gio mov r0,#0ah mov a,#020h movx @r0,a ;cho phep bo dao dong chay mov r0,#0ch movx a,@r0 ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx doc_data: mov r0,#0 mov r1,#10h x1: movx a,@r0 mov @r1,a inc r0 inc r0 inc r1 cjne r0,#06h,x1 movx a,@r0 mov @r1,a inc r1 inc r0 x2: movx a,@r0 mov @r1,a inc r0 inc r1 cjne r0,#0ah,x2 ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx doc_data_alr: mov r0,#01h movx a,@r0 mov 10h,a mov r0,#03h movx a,@r0 mov 11h,a mov r0,#05h movx a,@r0 mov 12h,a ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx hex_bcd: mov r0,#10h mov r1,#20h hb: mov a,@r0 mov b,#10 div ab mov @r1,b inc r1 mov @r1,a inc r0 inc r1 cjne r0,#13h,hb mov 26h,13h ; thu mov r0,#014h mov r1,#27h hb1: mov a,@r0 mov b,#10 div ab mov @r1,a inc r1 mov @r1,b inc r0 inc r1 cjne r0,#17h,hb1 ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx bcd_7doan: mov dptr,#900h mov r0,#20h mov r1,#30h ;chua cac ma data x3: mov a,@r0 ;lay giay movc a,@a+dptr mov @r1,a inc r0 inc r1 cjne r0,#2dh,x3 mov 3dh,3bh mov 3eh,3ch mov 3bh,#0a4h mov 3ch,#0c0h mov a,36h cjne a,#0f9h,exit3 mov 36h,#0c6h exit3: ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx hien_thi: mov r0,#30h mov a,#0feh ht: mov p0,@r0 mov p1,a lcall delay mov p1,#0ffh inc r0 rl a cjne a,#0feh,ht ht1: mov p0,@r0 mov p2,a lcall delay mov p2,#0ffh inc r0 rl a cjne a,#07fh,ht1 ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx hien_thi_alr: mov r0,#30h mov a,#0feh ht11: mov p0,@r0 mov p1,a lcall delay mov p1,#0ffh inc r0 rl a cjne a,#0bfh,ht11 ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ngat_n0: mov 4fh,10h mov 4eh,#6 mov r2,#1 clr bell reti ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx delay: mov 7fh,#100 djnz 7fh,$ ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx org 900h db 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h end
Một con 89 góc phải phía dưới định làm mạch nhạc bài "A time for us" mỗi khi đổ chuông, nhưng thất bại nên để trống đó!
Toàn làm rời và kết nối các module lại với nhau.
Module giờ phút giây
Module ngày tháng
Module năm
Mình dùng mấy con led 7 thanh to to, 5v ko sáng dc nên chơi điện 12V và qua ít trở 100R hạn dòng, các khóa đóng mở cho led sáng dc ghép darlington
Code của mình khi thay đổi, sửa chữa đâu đó, và bớt phần ko cần thiết ( cài giờ đổ chuông) để phù hợp!
Code:
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ; P0 data led, P1 quét led ngày tháng năm,P2 quét led giờ phút giây và thứ ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx dwn bit p3.3 up bit p3.4 mode bit p3.2 mode1 bit p3.0 bell bit p3.1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx org 000h jmp main org 003h jmp ngat_n0 main: mov r3,#0 lcall khoitaodallass lcall delay mov ie,#81h setb it0 tu_dau1: setb bell mov r2,#0 tu_dau: lcall doc_data lcall hex_bcd lcall bcd_7doan lcall hien_thi jnb mode,adj jnb mode1,adj_alr cjne r2,#0,ngat_bell sjmp tu_dau ngat_bell: lcall doc_data mov a,4fh add a,#2 cjne a,#60,kt_c23 kt_c23: jc tiep mov 4fh,10h jmp tu_dau tiep: cjne a,10h,tu_dau mov 4fh,10h cpl bell djnz 4eh,tu_dau mov r0,#0ch movx a,@r0 jmp tu_dau1 adj_alr: jmp set_alr ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx adj: lcall hien_thi jnb mode,adj mov 78h,#15 adj1: lcall hien_thi jnb mode,adj djnz 78h,adj1 inc r3 cjne r3,#08,loop mov r3,#0 ljmp tu_dau ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx loop: mov 67h,#10 loop3: mov 66h,#0afh loop1: lcall doc_data lcall hex_bcd lcall bcd_7doan lcall hien_thi jnb up,tang jnb dwn,giam1 jnb mode,adj djnz 66h,loop1 cjne r3,#1,tatphut mov 34h,#0ffh mov 35h,#0ffh sjmp tat tatphut: cjne r3,#02,tatgio mov 32h,#0ffh mov 33h,#0ffh sjmp tat tatgio: cjne r3,#03,tatthu mov 30h,#0ffh mov 31h,#0ffh sjmp tat tatthu: cjne r3,#04,tatngay mov 36h,#0ffh sjmp tat tatngay: cjne r3,#05,tatthang mov 37h,#0ffh mov 38h,#0ffh sjmp tat tatthang: cjne r3,#06,tatnam mov 39h,#0ffh mov 3ah,#0ffh sjmp tat tatnam: mov 3eh,#0ffh mov 3dh,#0ffh tat: mov 66h,#0afh loop2: lcall hien_thi jnb up,tang jnb dwn,giam1 jnb mode,adj2 djnz 66h,loop2 djnz 67h,loop3 mov r3,#0 ljmp tu_dau adj2: ljmp adj ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx giam1: ljmp giam ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx tang: mov 78h,#100 tang1: lcall hien_thi djnz 78h,tang1 cjne r3,#01h,ss1 mov r0,#04h movx a,@r0 inc a cjne a,#24,z1 mov a,#0 z1: movx @r0,a jmp loop ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss1: cjne r3,#02h,ss2 mov r0,#02h movx a,@r0 inc a cjne a,#60,z1 mov a,#0 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss2: cjne r3,#03,ss3 mov r0,#0h movx a,@r0 inc a cjne a,#060,z1 mov a,#0 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss3: cjne r3,#04,ss4 mov r0,#06h movx a,@r0 inc a cjne a,#08,z1 mov a,#01 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss4: cjne r3,#05,ss5 mov r0,#07h movx a,@r0 inc a cjne a,#032,z1 mov a,#00 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss5: cjne r3,#06,ss6 mov r0,#08h movx a,@r0 inc a cjne a,#013,z1 mov a,#01 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss6: mov r0,#09h movx a,@r0 inc a cjne a,#100,z1 mov a,#00 jmp z1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx giam: mov 78h,#100 giam11: lcall hien_thi djnz 78h,giam11 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx cjne r3,#01h,sss1 mov r0,#04 movx a,@r0 dec a cjne a,#0ffh,zz1 mov a,#23 zz1: movx @r0,a jmp loop ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss1: cjne r3,#02h,sss2 mov r0,#02h movx a,@r0 dec a cjne a,#0ffh,zz1 mov a,#59 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss2: cjne r3,#03h,sss3 mov r0,#0h movx a,@r0 dec a cjne a,#0ffh,zz1 mov a,#59 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss3: cjne r3,#04h,sss4 mov r0,#06h movx a,@r0 dec a cjne a,#0h,zz1 mov a,#7 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss4: cjne r3,#05h,sss5 mov r0,#07h movx a,@r0 dec a cjne a,#0ffh,zz1 mov a,#31 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss5: cjne r3,#06,sss6 mov r0,#08h movx a,@r0 dec a cjne a,#01h,zz1 mov a,#12 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss6: mov r0,#09 movx a,@r0 dec a cjne a,#0ffh,zz1 mov a,#99 jmp zz1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ; doan ct cai dat bao thuc set_alr: lcall hien_thi_alr jb mode1,set_alr set_a: inc r3 cjne r3,#4,wait mov r3,#0 ljmp tu_dau wait: mov 67h,#10 wait3: mov 66h,#0ffh lcall doc_data_alr lcall hex_bcd lcall bcd_7doan wait1: lcall hien_thi_alr jnb up,tang_alr jnb dwn,giam_alr jnb mode1,set_alr djnz 66h,wait1 cjne r3,#1,tatphut_alr mov 35h,#0ffh mov 34h,#0ffh sjmp tat_alr tatphut_alr: cjne r3,#2,tatgiay_alr mov 32h,#0ffh mov 33h,#0ffh sjmp tat_alr tatgiay_alr: mov 31h,#0ffh mov 30h,#0ffh tat_alr: mov 66h,#0ffh wait2: lcall hien_thi_alr jnb up,tang_alr jnb dwn,giam_alr jnb mode1,set_alr djnz 66h,wait2 djnz 67h,wait3 mov r3,#0 ljmp tu_dau ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx tang_alr: mov 78h,#200 tang1_alr: lcall hien_thi_alr djnz 78h,tang1_alr waitx3: cjne r3,#01h,ss_alr1 mov r0,#05h movx a,@r0 inc a cjne a,#24,z_alr1 mov a,#0 z_alr1: movx @r0,a jmp wait ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ss_alr1: cjne r3,#2,ss_alr2 mov r0,#03h movx a,@r0 inc a cjne a,#60,z_alr1 mov a,#0 jmp z_alr1 ss_alr2: mov r0,#01h movx a,@r0 inc a cjne a,#60,z_alr1 mov a,#0 jmp z_alr1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx giam_alr: mov 78h,#200 giam_alr11: lcall hien_thi_alr djnz 78h,giam_alr11 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx waity3: cjne r3,#01h,sss_alr1 mov r0,#5 movx a,@r0 dec a cjne a,#0ffh,zz_alr1 mov a,#24 zz_alr1: movx @r0,a jmp wait ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx sss_alr1: cjne r3,#2,sss_alr2 mov r0,#03h movx a,@r0 dec a cjne a,#0ffh,zz_alr1 mov a,#59 jmp zz_alr1 sss_alr2: mov r0,#01h movx a,@r0 dec a cjne a,#0ffh,zz_alr1 mov a,#59 jmp zz_alr1 ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx khoitaodallass: mov r0,#0bh mov a,#026h movx @r0,a ;cho phep chinh cai dat gio mov r0,#0ah mov a,#020h movx @r0,a ;cho phep bo dao dong chay mov r0,#0ch movx a,@r0 ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx doc_data: mov r0,#0 mov r1,#10h x1: movx a,@r0 mov @r1,a inc r0 inc r0 inc r1 cjne r0,#06h,x1 movx a,@r0 mov @r1,a inc r1 inc r0 x2: movx a,@r0 mov @r1,a inc r0 inc r1 cjne r0,#0ah,x2 ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx doc_data_alr: mov r0,#01h movx a,@r0 mov 10h,a mov r0,#03h movx a,@r0 mov 11h,a mov r0,#05h movx a,@r0 mov 12h,a ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx hex_bcd: mov r0,#10h mov r1,#20h hb: mov a,@r0 mov b,#10 div ab mov @r1,b inc r1 mov @r1,a inc r0 inc r1 cjne r0,#13h,hb mov 26h,13h ; thu mov r0,#014h mov r1,#27h hb1: mov a,@r0 mov b,#10 div ab mov @r1,a inc r1 mov @r1,b inc r0 inc r1 cjne r0,#17h,hb1 ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx bcd_7doan: mov dptr,#900h mov r0,#20h mov r1,#30h ;chua cac ma data x3: mov a,@r0 ;lay giay movc a,@a+dptr mov @r1,a inc r0 inc r1 cjne r0,#2dh,x3 mov 3dh,3bh mov 3eh,3ch mov 3bh,#0a4h mov 3ch,#0c0h mov a,36h cjne a,#0f9h,exit3 mov 36h,#0c6h exit3: ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx hien_thi: mov r0,#30h ht: mov p0,@r0 setb p2.0 lcall delay mov p2,#0 inc r0 mov p0,@r0 setb p2.1 lcall delay mov p2,#0 inc r0 mov p0,@r0 setb p2.2 lcall delay mov p2,#0 inc r0 mov p0,@r0 setb p2.3 lcall delay mov p2,#0 inc r0 mov p0,@r0 setb p2.4 lcall delay mov p2,#0 inc r0 mov p0,@r0 setb p2.5 lcall delay mov p2,#0 inc r0 mov p0,@r0 setb p2.6 lcall delay mov p2,#0 ht1: inc r0 mov p0,@r0 setb p1.0 lcall delay mov p1,#0 inc r0 mov p0,@r0 setb p1.1 lcall delay mov p1,#0 inc r0 mov p0,@r0 setb p1.2 lcall delay mov p1,#0 inc r0 mov p0,@r0 setb p1.3 lcall delay mov p1,#0 inc r0 mov p0,@r0 setb p1.4 lcall delay mov p1,#0 inc r0 mov p0,@r0 setb p1.5 lcall delay mov p1,#0 inc r0 mov p0,@r0 setb p1.6 lcall delay mov p1,#0 inc r0 mov p0,@r0 setb p1.7 lcall delay mov p1,#0 ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx hien_thi_alr: mov r0,#30h mov a,#0feh cpl a ht11: mov p0,@r0 mov p1,a lcall delay mov p1,#0ffh inc r0 rl a cjne a,#0bfh,ht11 ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ngat_n0: mov 4fh,10h mov 4eh,#6 mov r2,#1 clr bell reti ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx delay: mov 7fh,#100 djnz 7fh,$ ret ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx org 900h db 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h end
P/S: Cái này ko phải do mình viết ra, mình chỉ vẽ lại phần cứng, sửa code cho phù hợp với phần cứng mình thiết kế mà thôi (chủ yếu là sửa phần nút bấm với phần hiển thị). Các bạn có thể tham khảo file gốc để thay đổi phù hợp hơn
Thân
Comment