nah yang berikut ini adalah program JAM digital untuk IC Mikrokontroler AT89S52.
SILAHKAN dipelajari, di pahami dan di coba...
; Project name : Digital Clock.A51
; ==========================
Sat_detik equ 60h
Pul_detik equ 61h
Sat_menit equ 62h
Pul_menit equ 63h
Sat_jam equ 64h
Pul_jam equ 65h
;
Buffer1 equ 66h
Buffer2 equ 67h
Buffer3 equ 68h
Buffer4 equ 69h
Buffer5 equ 6ah
Buffer6 equ 6bh
;
Cacah equ 6ch
Info equ 6dh
Waktu equ -50000
;
org 0h
ljmp awal
;
org 3h
ljmp ext_int0
;
org 13h
ljmp ext_int1
;
org 0bh
ljmp timer_int0
;
org 30h
Awal: mov tmod,#1
mov th0,high waktu
mov tl0,low waktu
mov cacah,#20
setb ea
setb ex0
setb ex1
setb it0
setb it1
setb et0
setb tr0
call clear
mov dptr,#angka
;
Scan: mov a,sat_detik
movc a,@a+dptr
mov buffer1,a
mov p3,buffer1
mov p1,#11111110b
call delay
;
mov a,pul_detik
movc a,@a+dptr
mov buffer2,a
mov p3,buffer2
mov p1,#11111101b
call delay
;
mov p3,#0fdh
mov p1,#11111011b
call delay
;
mov a,sat_menit
movc a,@a+dptr
mov buffer3,a
mov p3,buffer3
mov p1,#11110111b
call delay
;
mov a,pul_menit
movc a,@a+dptr
mov buffer4,a
mov p3,buffer4
mov p1,#11101111b
call delay
;
mov p3,#0fdh
mov p1,#11011111b
call delay
;
mov a,sat_jam
movc a,@a+dptr
mov buffer5,a
mov p3,buffer5
mov p1,#10111111b
call delay
;
mov a,pul_jam
movc a,@a+dptr
mov buffer6,a
mov p3,buffer6
mov p1,#01111111b
call delay
;
jmp scan
;
Ext_int0:
inc sat_menit
mov a,sat_menit
cjne a,#10,back
mov sat_menit,#0
;
inc pul_menit
mov a,pul_menit
cjne a,#6,back
mov pul_menit,#0
Back: call debounce
reti
;
Ext_int1:
inc sat_jam
mov a,sat_jam
cjne a,#10,uji
mov sat_jam,#0
;
inc pul_jam
mov a,pul_jam
cjne a,#3,uji
mov pul_jam,#0
;
jmp back1
;
Uji: mov a,sat_jam
cjne a,#4,back1
mov a,pul_jam
cjne a,#2,back1
call clear
Back1: call debounce
reti
;
Timer_int0:
clr tr0
clr tf0
mov th0,#high waktu
mov tl0,#low waktu
djnz cacah,selesai
mov cacah,#20
call proses
Selesai:
setb tr0
reti
;
Proses: mov dptr,#angka
inc sat_detik
mov a,sat_detik
cjne a,#10,tamat
mov sat_detik,#0
;
inc pul_detik
mov a,pul_detik
cjne a,#6,tamat
mov pul_detik,#0
;
inc sat_menit
mov a,sat_menit
cjne a,#10,tamat
mov sat_menit,#0
;
inc pul_menit
mov a,pul_menit
cjne a,#6,tamat
mov pul_menit,#0
;
inc sat_jam
mov a,sat_jam
cjne a,#6,check
mov sat_jam,#0
;
inc pul_jam
mov a,pul_jam
cjne a,#2,check
mov pul_jam,#0
;
jmp tamat
;
Check: mov a,sat_jam
cjne a,#4,tamat
mov a,pul_jam
call clear
Tamat:
ret
;
Clear: mov sat_detik,#0
mov pul_detik,#0
mov sat_menit,#0
mov pul_menit,#0
mov sat_jam,#0
mov pul_jam,#0
mov buffer1,#22h
mov buffer2,#22h
mov buffer3,#22h
mov buffer4,#22h
mov buffer5,#22h
mov buffer6,#22h
ret
;
Delay:
mov r0,#0
Loop: djnz r0,$
mov p3,#0ffh
mov p1,#0ffh
ret
;
Debounce:
mov r1,#0
Tunggu: djnz r1,tunggu
ret
;
Angka:
db 22h,0fah,0a4h,25h,71h,29h,28h,67h,20h,21h,22h
End
kalau ada pertanyaan, silahkan sampaikan di bagian komentar yaa... :)
----- *Jangan Lupa Komentarnya ya?* -----