JAM DIGITAL COUNTER DOWN
Gambar 6.5. Format tampilan jam, menit dan detik
;Percobaan Timer dengan counting DOWN
;Rencanakan program assembly untuk pembuatan jam digital JJ:MM:DD
;========================================================
;Project Jam Digital Counter Down
;Dengan menggunakan LCD Character
;Visit elektronika-elektronika.blogspot.com
;=========================================================
pencacah20 equ 70h
menit equ 72h
jam equ 73h
menit1 equ 74h
menit10 equ 75h
jam1 equ 76h
jam10 equ 77h
detik equ 78h
detik1 equ 79h
detik10 equ 7ah
dispclr equ 00000001b
funcset equ 00111000b
entrmod equ 00000110b
dispon equ 00001100b
org 0h
ljmp start
org 3h
reti
org 0bh
ajmp timerinterrupt
org 13h
reti
org 23h
reti
start: mov pencacah20,#20
mov detik,#60
mov jam,#60
mov menit,#60
acall perbaruitampilan
anl TMOD,#11110000b
orl TMOD,#00000001b
mov th0,#03ch
mov tl0,#0afh
setb ET0
setb EA
setb TR0
acall init_lcd
;
scandisplay:
;
mov r1,#8ch
acall write_inst
mov r1,detik1
acall write_data
;
mov r1,#8bh
acall write_inst
mov r1,detik10
acall write_data
;
mov r1,#89h
acall write_inst
mov r1,menit1
acall write_data
;
mov r1,#88h
acall write_inst
mov r1,menit10
acall write_data
;
mov r1,#86h
acall write_inst
mov r1,jam1
acall write_data
;
mov r1,#85h
acall write_inst
mov r1,jam10
acall write_data
;
sjmp scandisplay
;
;
write_inst:
clr P1.0
mov P0,R1
setb P1.1
acall delay
clr P1.1
ret
;
write_data:
setb P1.0
mov P0,R1
setb P1.1
acall delay
clr P1.1
ret
;
delay: mov R0,#0
delay1: mov R2,#50
djnz R2,$
djnz R0,delay1
ret
;
;================================
;PROCEDURE INISIALISAS
; LCD KARAKTER 2 X 16
;===============================
init_lcd:
acall delay
acall delay
acall delay
mov r1,#dispclr
acall write_inst
mov r1,#funcset
acall write_inst
mov r1,#dispon
acall write_inst
mov r1,#entrmod
acall write_inst
ret
;
timerinterrupt:
mov tl0,#0afh
mov th0,#03ch
djnz pencacah20,selesaiinterupsi
mov pencacah20,#20
;
acall jamdigital
djnz pencacah60,selesaiinterupsi
mov pencacah60,#60
;
acall jamdigital
selesaiinterupsi:
reti
;
jamdigital:
dec detik
mov a,#0
cjne a,detik,perbaruitampilan
mov detik,#60
;
satumenit:
dec menit
mov A,#0
cjne A,menit,perbaruitampilan
mov menit,#60
;
satujam:
dec jam
mov A,#0
cjne A,jam,perbaruitampilan
mov jam,#60
;
perbaruitampilan:
mov a,detik
mov b,#10
div ab
mov detik1,b
mov detik10,a
;
mov a,menit
mov b,#10
div ab
mov menit1,b
mov menit10,a
;
mov a,jam
mov b,#10
div ab
mov jam1,b
mov jam10,a
;
mov a,#30h
add a,detik1
mov detik1,a
;
mov a,#30h
add a,detik10
mov detik10,a
;
mov a,#30h
add a,menit1
mov menit1,a
;
mov a,#30h
add a,menit10
mov menit10,a
;
mov a,#30h
add a,jam1
mov jam1,a
;
mov a,#30h
add a,jam10
mov jam10,a
;
ret
end
3 comments:
kalo yg 7segmen ada g bang?
kalo kode datas pake simulator midlet nyeting tampilan lcdnya gmn y bang??
mhon bimbingannya..trm ksh.
rendyalanuari@gmail.com
Salam kenal,mas sy banyak lcd 20x16 tapi masih baik,mohon bantuanya untuk rangkaian jam digital pakai ic 89s51 dangan ic Dallas ds1287 beserta setting program ASM nya.atau mas punya rangkaian lain,tentunya pakai ic 89s51 terimakasih sebelumya
shiddiq@ptwahyu.com
gan...koq pas d klik assm d edsim 51 ada yg error d djnz pencacah 60 gan ?
thx
Post a Comment