Subscribe:

Minggu, 12 Januari 2014

Membuat tulisan berjalan di LCD

Nama : Diah Hanggraeni
NIM   : 11.11.2339
Kelas  : TI 11 A

Tugas Mikroprosesor
Membuat tulisan berjalan di LCD yang ditampilkan ditopview simulator



Berikut kode program untuk membuat tulisan Diah h dan nim berjalan 

$mod51
geserLequ 00011011b ; 0 0 0 1 S/C R/L X X
geserRequ 00011111b ; 0 0 0 1 S/C R/L X X
org 000h
clr p3.5
callinit_LCD
start: call write_char
;callinit_LCD
call write_char2
callgeser
sjmp start
;
geser:
mov R6,#40 ;R7 = 40; gesersebanyak 40 karakter
lagi: mov R1,#geserR ;R1 = GeserRight
callwrite_inst
callldelay
djnz R6,lagi ;R7=R7-1, jika R7 ? 0 makalompatkelagi
write_char:
mov dptr,#word1 ;DPTR = [ address word1 ]
mov r3,#21 ;R3=16,number character to be display
mov r1,#80h ;R1=80h,address DDRAM start position
callwrite_inst
;

write1:clr a ; A = 0

movc a,@a+dptr ; A = [A+ DPTR]
mov r1,A ; R1 = A
incdptr ; DPTR = DPTR +1
callwrite_data;
djnz r3,write1 ; R3 = R3-1,
ret

write_char2:
mov dptr,#word2 ;DPTR = [ address word1 ]
mov r3,#23 ;R3=16,number character to be display
mov r1,#0C0h ;R1=80h,address DDRAM start position
callwrite_inst
;
write2:clr a ; A = 0

movc a,@a+dptr ; A = [A+ DPTR]
mov r1,A ; R1 = A
incdptr ; DPTR = DPTR +1
callwrite_data;
djnz r3,write2 ; R3 = R3-1,
ret

;
Init_lcd:
mov r1,#00000001b ;Display clear
callwrite_inst ;
mov r1,#00111000b ;Function set,
;Data 8 bit,2 line font 5x7
callwrite_inst ;
mov r1,#00001100b ;Display on,
;cursoroff,cursor blink off
callwrite_inst
mov r1,#00000110b ;Entry mode, Set increment
callwrite_inst
ret
;
Write_inst:
clr P3.6 ; RS = P2.0 = 0, write mode instruction
mov P0,R1 ; D7 s/d D0 = P0 = R1
setb P3.7 ; EN = 1 = P2.1
call delay ; call delay time
clr P3.7 ; EN = 0 = P2.1
ret
;
Write_data:
setb P3.6 ; RS = P2.0 = 1, write mode data
mov P0,R1 ; D7 s/d D0 = P0 = R1
setb P3.7 ; EN = 1 = P2.1
call delay ; call delay time
clr p3.7 ; EN = 0 = P2.1
ret
;
Ldelay: mov R2,#080h
Ld1: acall delay
djnz R2,Ld1
ret
delay: mov R0,#0
delay1: mov R7,#0fh
djnz R7,$
djnz R0,delay1
ret
;
word1: DB '               Diah H.'; here is the data to be look up
word2: DB '             11.11.2339'; here is the data to be look up
;

end

Dan ini adalah tampilan saat tulisan berjalan


0 komentar:

Posting Komentar