/*已试验证明
AT89C52与LCD12864
未用BF(忙信号)查询,延时1ms
不能进行BF查询*/
rs bit p2.4
rw bit p2.5
e bit p2.6
psb bit p2.1
res bit p2.3
com equ 30h
date equ 31h
org 0000h
sjmp main
org 0030h
main:mov p0,#00h
mov p2,#10000111b
lcall delay
setb res
mov sp,#60h
lcall init
lcall page1
clr p1.7
sjmp $
init:mov com,#00110000b;根本指令集操作
lcall write_com
mov com,#00000001b;清屏
lcall write_com
mov com,#00000010b;AC地址清零
lcall write_com
mov com,#00000110b;DDRAM地址计数器加一
lcall write_com
mov com,#00001110b;开显现,显现游标
lcall write_com
mov com,#00010100b;
lcall write_com
ret
page1:mov com,#80h
lcall write_com
mov dptr,#tab1
lcall line
mov com,#90h
lcall write_com
mov dptr,#tab2
lcall line
mov com,#88h
lcall write_com
mov dptr,#tab3
lcall line
mov com,#98h
lcall write_com
mov dptr,#tab4
lcall line
RET
line: mov r0,#10h
mov r1,#00
N1:mov a,r1
movc a,@a+dptr
mov date,a
lcall write_date
inc r1
lcall delay
djnz r0,N1
ret
write_com:clr rs
clr rw
mov p0,com
setb e
lcall delay
clr e
ret
write_date:setb rs
clr rw
mov p0,date
setb e
lcall delay
clr e
ret
tab1: db”有用开关电源手册”
tab2: db”Lcent Technologi”
tab3: db”51单片机开发原理”
tab4: db”STC89C52_LCD1286″
DELAY: ;差错 0us
MOV R7,#1H
DL1:
MOV R6,#8EH
DL0:
MOV R5,#02H
DJNZ R5,$
DJNZ R6,DL0
DJNZ R7,DL1
RET
end
============================================================================================
/*已试验证明
AT89C52与LCD12864
未用BF(忙信号)查询,延时1ms
不能进行BF查询*/
#include
#define uint unsigned int
#define uchar unsigned char
uchar t,i,j;
uchar code table1[]=”图形以及字符显现”;
uchar code table2[]=”2009年 7月 29 日”;
uchar code table3[]=”设计者:赵玉庆 “;
uchar code table4[]=”AT89C52 与ST7920″;
sbit rs=P2^4;
sbit rw=P2^5;
sbit e=P2^6;
sbit psb=P2^1;
sbit res=P2^3;
void delay() //差错 0us
{
unsigned char a,b,c;
for(c=1;c>0;c–)
for(b=142;b>0;b–)
for(a=2;a>0;a–);
}
void write_com(uchar com)
{
rs=0;
rw=0;
P0=com;
e=1;
delay();
e=0;
}
void write_date(uchar date)
{
rs=1;
rw=0;
P0=date;
e=1;
delay();
e=0;
}
void init()
{
write_com(0x30);
write_com(0x01);
write_com(0x02);
write_com(0x06);
write_com(0x0c);
write_com(0x14);
}
void disp()
{
write_com(0x80);
for(i=0;i<16;i++)
{
write_date(table1[i]);
delay();
}
write_com(0x90);
for(j=0;j<16;j++)
{
write_date(table2[j]);
delay();
}
write_com(0x88);
for(i=0;i<16;i++)
{
write_date(table3[i]);
delay();
}
write_com(0x98);
for(j=0;j<16;j++)
{
write_date(table4[j]);
delay();
}
}
void main()
{
rs=0;//根本状况初始化
rw=0;
e=0;
res=0;
delay();
res=1;//复位
psb=1;//挑选8BIT数据线
SP=0x30;
init();
disp();
while(1);
}