📄 anim.asm
字号:
;*********************************************************************
;THIS CODE WILL DISPAY A CHARACTER "G" ON LCD AND SINK THE CHAR DOWNWARDS
;*********************************************************************
org 0000h
;*********************************************************************
;PORT DEFINED (CAN BE MODIFIED ACCORING TO CIRCUIT
;*********************************************************************
;p0= d0-d7
;RS rs=0 for command rs=1 for data
;RW wr=0 for write wr=1 for read
;EN enable -\_
RS equ p3.5
RW equ p3.4
EN equ p3.3
;*********************************************************************
;TO INITIALIZE THE LCD
;*********************************************************************
mov a,#38h ;2 line 5x7
acall command
mov a,#0ch ;lcd on cursor on
acall command
mov a,#01h ;clr lcd
acall command
mov a,#06h ;shift cursor right
acall command
mov a,#'a' ; testing for "a"
acall ddisp
acall delay
acall writech ;writes char in CG ram of lcd
mov a,#80h ;go to start of lcd
acall command
mov a,#01h
acall command ;clr disp
;*********************************************************************
;LOOP FOR DISPLAYING 8 ROW (1CHAR) STORED IN CG RAM
;*********************************************************************
s:
mov r0,#00h ;CGram address
again1: mov a,#85h ;DDRAM addres display position on lcd
acall command
acall delay
mov a,r0 ; r0=0 means first char of cg ram
acall ddisp ; display on lcd
inc r0 ; inc counter
cjne r0,#08h,again1
sjmp s ; main loop reapet
command:acall ready ;chk lcd is ready to accept command
mov p0,a
clr RS ;rs=0 for command
clr RW ;wr=0 for write
setb EN
clr EN
ret
ddisp: acall ready
mov p0,a
setb RS ;rs=1 for data
clr RW ;wr=0 for write
setb EN
clr EN
ret
ready: setb p0.7
clr RS ;rs=0 command
setb RW ;wr=1 read
back: clr EN ;enable
setb EN
jb p0.7,back
ret
delay: mov r7,#99h
w2: mov r6,#00h
w1: djnz r6,w1
djnz r7,w2
ret
writech:acall ready
mov a,#40h ; go to 00 of cgram
mov p0,a
clr RW
clr RS
setb EN
clr EN
mov r7,#64 ;counter for 64 times 8pix hor x 8lines = 1 char
mov dptr,#tabel ;load address values of tabel
wr1: clr a
acall ready
movc a,@a+dptr
mov p0,a ; this will write tabel in cgram (address 40 of lcd
setb RS
clr RW
setb EN
clr EN
inc dptr
djnz r7,wr1
ret
;*********************************************************************
;TABEL FOR 8 CHAR
;MADE SUCH THAT CHAR "G" IS SINKING DOWN
;*********************************************************************
tabel:
db 00001110b ;char 1 of CGRAM
db 00010001b ;1=high pixel
db 00010000b ;0=low pix
db 00010000b
db 00010011b
db 00010001b
db 00010001b
db 00001110b
db 00000000b
db 00001110b ;char 2 of CGRAM
db 00010001b ;1=high pixel
db 00010000b ;0=low pix
db 00010000b
db 00010011b
db 00010001b
db 00010001b
db 00000000b
db 00000000b
db 00001110b ;char 3 of CGRAM
db 00010001b ;1=high pixel
db 00010000b ;0=low pix
db 00010000b
db 00010011b
db 00010001b
db 00000000b
db 00000000b
db 00000000b
db 00001110b ;char 4 of CGRAM
db 00010001b ;1=high pixel
db 00010000b ;0=low pix
db 00010000b
db 00010011b
db 00000000b
db 00000000b
db 00000000b
db 00000000b
db 00001110b ;char 5 of CGRAM
db 00010001b ;1=high pixel
db 00010000b ;0=low pix
db 00010000b
db 00000000b
db 00000000b
db 00000000b
db 00000000b
db 00000000b
db 00001110b ;char 6 of CGRAM
db 00010001b ;1=high pixel
db 00010000b ;0=low pix
db 00000000b
db 00000000b
db 00000000b
db 00000000b
db 00000000b
db 00000000b
db 00001110b ;char 7 of CGRAM
db 00010001b ;1=high pixel
db 00000000b
db 00000000b
db 00000000b
db 00000000b
db 00000000b
db 00000000b
db 00000000b
db 00001110b ;char 8 of CGRAM
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -