STC89C52R并行驅(qū)動(dòng)LCD12864(asm/c51)
AT89C52與LCD12864
未用BF(忙信號(hào))查詢,延時(shí)1ms
不能進(jìn)行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地址計(jì)數(shù)器加一
lcall write_com
mov com,#00001110b;開(kāi)顯示,顯示游標(biāo)
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"實(shí)用開(kāi)關(guān)電源手冊(cè)"
tab2: db"Lcent Technologi"
tab3: db"51單片機(jī)開(kāi)發(fā)原理"
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
============================================================================================
/*已實(shí)驗(yàn)論證
AT89C52與LCD12864
未用BF(忙信號(hào))查詢,延時(shí)1ms
不能進(jìn)行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[]="設(shè)計(jì)者:趙玉慶 ";
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;//基本狀態(tài)初始化
rw=0;
e=0;
res=0;
delay();
res=1;//復(fù)位
psb=1;//選擇8BIT數(shù)據(jù)線
SP=0x30;
init();
disp();
while(1);
}
評(píng)論