求助12864程序出错了
刚刚接触mcu,遇到12864的问题,编写程序显示汉字,前三行正常显示,第四行不显示程序如下
#include
#define uchar unsigned char
#define uint unsigned int
sbit lcdrs =P2^0;
sbit lcdrw =P2^1;
sbit lcden =P2^2;
sbit lcdpsb=P2^3;
uchar temp1[]="12864 基础显示";
uchar temp2[]="2012年02月05日";
uchar temp3[]="我爱MCU";
uchar temp4[]="123456";
void delay (uint z) //延时函数
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
write_com(uchar com)
{
uchar temp=0;
lcdrs=0;
lcdrw=1;
/*do//读是否忙碌
{
lcden=1;
delay(5);
temp=P0;
lcden=0;
}
while(temp&0x80);*/
lcdrw=0;
P0=com;
lcden=1;
delay(5);
lcden=0;
}
void lcdinit()
{
lcdrs=1;
write_com(0x30);
delay(5);
write_com(0x02);
delay(5);
write_com(0x0c);
delay(5);
write_com(0x01);
delay(5);
write_com(0x06);
}
write_date(uchar date)
{
uchar temp=0;
lcdrs=0;
lcdrw=1;
do
{
lcden=1;
delay(5);
temp=P0;
lcden=0;
}
while(temp&0x80);
lcdrs=1;
lcdrw=0;
P0=date;
lcden=1;
delay(5);
lcden=0;
}
void main()
{
int i=0;
lcdpsb=1;
lcdinit();
write_com(0x80);//第一行地址
for(i=0;i<14;i++)
write_date(temp1);
write_com(0x90);//第二行地址
for(i=0;i<16;i++)
write_date(temp2);
write_com(0x88);//第三行地址
for(i=0;i<7;i++)
write_date(temp3);
write_com(0x98);//第四行地址
for(i=0;i<6;i++);
write_date(temp4);
while(1);
}
有知道的帮帮小弟吧,感激不尽
提问者:wtefewrws
地点:-
浏览次数:1245
提问时间:04-21 08:36
我有更好的答案