#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit lcde=P2^7;
sbit lcdrs=P2^6;
sbit lcdrw=P2^5;
void init();
void delay(uint z);
void writecom(uchar com);
void writedate(uchar date);
void main()
{
init();
delay(100);
writedate('m'); //问题出在这里,输入'm',液晶屏幕上显示o 小弟调试了好长时间,延时加长,初始化也检查了几遍, 还是没解决问题,
delay(100);
writedate(0x44); //问题出在这里,输入'D',液晶屏幕上显示F 求大神不吝赐教!现行拜谢!附上液晶PDF资料。
delay(100);
writedate('V');
while(1);
}
void init()
{
lcde=0;
lcdrs=0;
lcdrw=0;
//writecom(0x02);
writecom(0x38);
delay(100);
writecom(0x0e);
delay(100);
writecom(0x06);
delay(100);
writecom(0x01);
delay(100);
lcdrs=1;
delay(10);
}
void writecom(uchar com)
{
lcdrs=0;
lcdrw=0;
P0=com;
delay(100);
lcde=1;
delay(100);
lcde=0;
}
void writedate(uchar date)
{
lcdrs=1;
lcdrw=0;
P0=date;
delay(100);
lcde=1;
delay(100);
lcde=0;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
} |