DEMO INTERFACE KEYBOARD DAN PROSES PENYIMPANAN KE RAM
;=======================================================
; DEMO INTERFACE KEYBOARD DAN PROSES PENYIMPANAN KE RAM
; elektronika-elektronika.blogspot.com
; Baca referensi tentang Keyboard PC pada BAB IX
;=======================================================
dispclr equ 00000001b
funcset equ 00111000b
entrmod equ 00000110b
dispon equ 00001100b
KbdData bit P3.3
KbdClock bit INT0;P3.2
busy bit P3.5
Strobe bit P3.4
DataKeyboard equ 30h
CounterDDRAM equ 31h
CounterEnter equ 32h
DataKeysave equ 33h
;
org 0h
nop
acall init_LCD
acall LCD_cursor
acall LCD_Nama
acall print_Kursor
acall LCD_Tanggal
mov R2,#86h
mov CounterDDRAM,#86h
mov CounterEnter,#0
mov DataKeySave,#60h; 60h s/d 6ah nama dan tgl. 70h s/d 7ah
acall init_data
;
Forever:
JB KbdClock,$
acall ambilKeyboard
jnc Forever
acall LCD_Out
clr C
sjmp Forever
;
Processing:
acall Init_LCD
again:acall Display_Proses
acall audiometer
acall delay
acall delay
acall LCD_Stop
acall delay
acall delay
acall init_LCD
acall delay
acall delay
acall LCD_Loading
acall delay
acall delay
;
acall LCD_Nama
Acall LCD_Tanggal
acall Display_OpenData
dead: sjmp dead
;
AmbilKeyboard:
acall ambil_scancode
cjne a,#0F0h,kybd_tidakLepas
JB KbdClock,$
acall ambil_Scancode
Setb C
Acall Konversi_Scancode
ret
;
Kybd_tidakLepas:
Clr C
ret
;
Konversi_ScanCode:
Mov DPTR,#TableKeyboard
movc A,@A+DPTR
mov DataKeyboard,A
ret
;
LCD_Out:
mov R0,DataKeySave
mov A,CounterDDRAM
mov R7,A
acall write_inst
mov A,DataKeyboard
cjne A,#08h,Out ;Deteksi Tombol Back Space
acall Bckspace
sjmp OUt2
Out: cjne A,#0Ah,Out1 ;Deteksi Tombol Enter
mov CounterDDRAM,#0C6h
acall Enter
sjmp Out2
Out1: mov R7,A
mov @R0,A
acall write_data
inc CounterDDRAM
inc DataKeySave
out2: ret
;
BckSpace:
Dec CounterDDRAM
Dec DataKeySave
mov A,CounterDDRAM
mov R7,A
acall write_inst
mov R7,#' '
acall write_data
ret
;
Enter: inc CounterEnter
mov A,CounterEnter
mov DataKeySave,#70h ;alamat awal peyimpanan data tanggal
cjne A,#2,OutE1
LJMP Processing
OutE1: Mov A,CounterDDRAM
Mov R7,A
acall write_inst
OutE2: ret
;
init_lcd:
mov R7,#dispclr
acall write_inst
mov R7,#funcset
acall write_inst
mov R7,#dispon
acall write_inst
mov R7,#entrmod
acall write_inst
ret
;
Ambil_scanCode:
clr A
Jnb KbdClock,$
mov R0,#08h
Ambil_ScanCode2:
Jb KbdClock,$
Mov C,KbdData
Rr A
mov acc.7,C
Jnb KbdClock,$
Djnz R0,Ambil_ScanCode2
Jb KbdClock,$
Jnb KbdClock,$
Jb KbdClock,$
Jnb KbdClock,$
ret
;
Write_inst:
Clr P3.6 ; RS = P1.0 = 0, mode tulis instruksi ke LCD
Mov P0,R7 ; D7 s/d D0 = P0 = R1
Setb P3.7 ; EN = 1 = P1.1
Acall delay ; panggil waktu tunda
Clr P3.7 ; EN = 0 = P1.1
ret
;
Write_data:
Setb P3.6 ; RS = P1.0 = 1, mode tulis data ke LCD
Mov P0,R7 ; D7 s/d D0 = P0 = R1
Setb P3.7 ; EN = 1 = P1.1
Acall delay ; panggil waktu tunda
Clr p3.7 ; EN = 0 = P1.1
ret
;
LCD_ON: mov R7,#00001100b
acall write_inst
ret
;
LCD_OFF:mov R7,#00001000b
acall write_inst
ret
;
LCD_Cursor:
mov R7,#00001111b
acall write_inst
ret
;
Print_Kursor:
mov R7,#86h
acall write_inst
mov R7,#'_'
acall write_data
ret
;
delay: mov R5,#0
delay1:mov R4,#02fh
djnz R4,$
djnz R5,delay1
ret
;
;
LCD_Nama: mov dptr,#tulisnama; DPTR = [ tulisan1 ]
mov r6,#16 ; R3 = 16, jumlah karakter yang akan ditampilkan
mov r7,#80h ; R1 = 80h, Posisi karakter baris 1 mulai kolom 1
acall write_inst
Nama: clr a ; A = 0
movc a,@a+dptr ; A = [A+ DPTR]
mov r7,A ; R1 = A
inc dptr ; DPTR = DPTR +1
acall write_data
djnz r6,nama ; R3 = R3-1, lompat ke tulis1 jika R3 ? 0
ret
;
LCD_Tanggal:mov dptr,#tulistanggal; DPTR = [ tulisan1 ]
mov r6,#16 ; R3 = 16, jumlah karakter yang akan ditampilkan
mov r7,#0C0h ; R1 = 80h, Posisi karakter baris 1 mulai kolom 1
acall write_inst
tanggal: clr a ; A = 0
movc a,@a+dptr ; A = [A+ DPTR]
mov r7,A ; R1 = A
inc dptr ; DPTR = DPTR +1
acall write_data
djnz r6,tanggal ; R3 = R3-1, lompat ke tulis1 jika R3 ? 0
ret
;
LCD_Proses: mov dptr,#tulisProses; DPTR = [ tulisan1 ]
mov r6,#16 ; R3 = 16, jumlah karakter yang akan ditampilkan
mov r7,#080h ; R1 = 80h, Posisi karakter baris 1 mulai kolom 1
acall write_inst
Proses: clr a ; A = 0
movc a,@a+dptr ; A = [A+ DPTR]
mov r7,A ; R1 = A
inc dptr ; DPTR = DPTR +1
acall write_data
djnz r6,Proses ; R3 = R3-1, lompat ke tulis1 jika R3 ? 0
ret
;
LCD_Wait: mov dptr,#tulisWait; DPTR = [ tulisan1 ]
mov r6,#16 ; R3 = 16, jumlah karakter yang akan ditampilkan
mov r7,#0C0h ; R1 = 80h, Posisi karakter baris 1 mulai kolom 1
acall write_inst
wait: clr a ; A = 0
movc a,@a+dptr ; A = [A+ DPTR]
mov r7,A ; R1 = A
inc dptr ; DPTR = DPTR +1
acall write_data
djnz r6,wait ; R3 = R3-1, lompat ke tulis1 jika R3 ? 0
ret
;
LCD_Loading:mov dptr,#tulisloading; DPTR = [ tulisan1 ]
mov r6,#16 ; R3 = 16, jumlah karakter yang akan ditampilkan
mov r7,#080h ; R1 = 80h, Posisi karakter baris 1 mulai kolom 1
acall write_inst
loading: clr a ; A = 0
movc a,@a+dptr ; A = [A+ DPTR]
mov r7,A ; R1 = A
inc dptr ; DPTR = DPTR +1
acall write_data
djnz r6,loading ; R3 = R3-1, lompat ke tulis1 jika R3 ? 0
ret
;
LCD_Stop: mov dptr,#tulisStop; DPTR = [ tulisan1 ]
mov r6,#16 ; R3 = 16, jumlah karakter yang akan ditampilkan
mov r7,#0C0h ; R1 = 80h, Posisi karakter baris 1 mulai kolom 1
acall write_inst
Stop: clr a ; A = 0
movc a,@a+dptr ; A = [A+ DPTR]
mov r7,A ; R1 = A
inc dptr ; DPTR = DPTR +1
acall write_data
djnz r6,Stop ; R3 = R3-1, lompat ke tulis1 jika R3 ? 0
ret
;
Display_OpenData:
mov counterDDRAM,#86h
mov R0,#60h
;
Open: mov A,CounterDDRAM
cjne A,#090h,Open1
sjmp Open2
Open1: mov R7,A
acall write_inst
inc CounterDDRAM
;
mov A,@R0
mov R7,A
acall write_data
inc R0
sjmp Open
Open2:
mov counterDDRAM,#0c6h
mov R0,#70h
;
Open3: mov A,CounterDDRAM
cjne A,#0D0h,Open4
sjmp Open5
Open4: mov R7,A
acall write_inst
inc CounterDDRAM
;
mov A,@R0
mov R7,A
acall write_data
inc R0
sjmp Open3
open5: ret
;
Init_data:
mov R0,#60h
lagi: mov @R0,#' '
inc R0
mov A,R0
cjne A,#06fh,lagi
;
mov R0,#70h
lagi1: mov @R0,#' '
inc R0
mov A,R0
cjne A,#07fh,lagi1
ret
;
Display_Proses:
acall LCD_ON
acall LCD_Proses
acall LCD_Wait
acall LCD_OFF
acall delay
acall delay
acall delay
ret
;
Tulisnama:
DB 'NAMA: '
Tulistanggal:
DB 'Tgl.: '
TulisProses:
DB 'Processing......'
TulisWait:
DB ' Wait '
TulisStop:
DB 'End of Process '
TulisLoading:
DB ' Loading Data...'
TableKeyboard:
DB 00
DB 0F9H
DB 00
DB 0F5H,0F3H,0F1H,0F2H,0FCH
DB 00H
DB 0FAH,0F8H,0F6H,0F4H
DB 0C0H
DB '~'
DB 00H
DB 00H
DB 0C1H
DB 0C2H
DB 00H
DB 0C3H
DB 'Q1'
DB 00H,00H,00H
DB 'ZSAW2'
DB 00H,00H
DB 'CXDE43'
DB 00H,00H
DB ' VFTR5'
DB 00H,00H
DB 'NBHGY6'
DB 00H,00H,00H
DB 'MJU78'
DB 00H,00H
DB ',KIO09'
DB 00H,00H
DB './L;P-'
DB 00H,00H,00H
DB 27H
DB 00H
DB '[='
DB 00H,00H
DB 0C5H
DB 0C6H
DB 0AH
DB ']'
DB 00H
DB '\'
DB 00H,00H,00H,00H,00H,00H,00H,00H
DB 08H
DB 00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H
DB 0DH
DB 00H
DB 0FBH
DB 00H,00H,00H,00H,00H,00H,00H,00H,00H,00H
DB 0F7H
end
No comments:
Post a Comment