微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > LCD12864的串口驱动(asm/c51)

LCD12864的串口驱动(asm/c51)

时间:11-10 来源:互联网 点击:

DISB1:DB "昨夜星辰昨夜风,"
DISB2:DB "画楼西畔桂堂东。"
DISB3:DB "身无彩凤双飞翼,"
DISB4:DB "心有灵犀一点通。"
DISB5:DB "隔座送钩春酒暖,"
DISB6:DB "分曹射覆蜡灯红。"
DISB7:DB "嗟余听鼓应官去,"
DISB8:DB "走马兰台类转蓬。"

END

.......................lcd12864 串口驱动程序(c51:已调试过).................................................

#include
#define uchar unsigned char
sbit cs=P2^4;
sbit sid=P2^5;
sbit clk=P2^6;
sbit psb=P2^1;
sbit res=P2^3;
uchar a,i;
uchar code table1[]="实用开关电源手册";
uchar code table2[]="Lcent Technologi";
uchar code table3[]="51单片机开发原理";
uchar code table4[]="STC89C52_LCD1286";

void d1ms(void) //误差 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 d10ms(void) //误差 0us
{
unsigned char a,b,c;
for(c=1;c>0;c--)
for(b=38;b>0;b--)
for(a=130;a>0;a--);
}

void synbit()
{
uchar j;
sid=1;
for(j=0;j<5;j++)
{
clk=1;
clk=0;
}
}

void zorn()
{
uchar j;
for(j=0;j<4;j++)
{
sid=0;
clk=1;
clk=0;
}
}

void send(uchar date)
{
uchar j;
for(j=0;j<4;j++)
{
sid=(bit)(date&0x80);
clk=1;
clk=0;
date=date<1;
}
zorn();
for(j=0;j<4;j++)
{
sid=(bit)(date&0x80);
clk=1;
clk=0;
date=date<1;
}
zorn();
}

void write_com(uchar com)
{
uchar j;
cs=1;
synbit();
sid=0;
for(j=0;j<3;j++)
{
clk=1;
clk=0;
}
send(com);
cs=0;
d1ms();
}

void init()
{
write_com(0x30);
write_com(0x30);
write_com(0x01);
write_com(0x02);
write_com(0x06);
write_com(0x0c);
write_com(0x14);
}

void write_date(uchar date)
{
cs=1;
synbit();
sid=0;
clk=1;
clk=0;
sid=1;
clk=1;
clk=0;
sid=0;
clk=1;
clk=0;
send(date);
cs=0;
d1ms();
}
void displcd()
{
write_com(0x80);
for(i=0;i<0x10;i++)
{
write_date(table1[i]);
}
write_com(0x88);
for(i=0;i<0x10;i++)
{
write_date(table2[i]);
}
write_com(0x90);
for(i=0;i<0x10;i++)
{
write_date(table3[i]);
}
write_com(0x98);
for(i=0;i<0x10;i++)
{
write_date(table4[i]);
}
}

void main()
{
cs=0;
sid=0;
clk=0;
SP=0x30;
res=0;
d10ms();
res=1;
psb=0;
init();
displcd();
while(1);
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top