最近再做个非接触式红外温度测量,用LCD1602显示,但第一行全部一直显示黑块,百度了下是初始化问题,求问怎么解决
void delay1(uint x) //延时函数1
{
while(x--);
}
char Busy(){ //忙碌
char a=0;
rs=0,rw=1,lcden=1;
if(P0&0x80==0x80)a=1;
lcden=0;
return a;}
void write_cmd(uchar cmd) //写命令函数{ while(Busy());
delay1(100); rs=0; //写命令 rw=0;
lcden=0;
delay1(100);
P0=cmd;
delay(100);
lcden=1;
delay1(100);
lcden=0;}
void write_data(uchar dat) //写数据函数{ while(Busy());
delay(100);
rs=1; //写入数据
rw=0;
lcden=0;
delay1(100);
P0=dat;
delay1(100);
lcden=1;
delay1(100);
lcden=0;}
void init() //初始化函数{ rs=0;
rw=0;
lcden=0;
write_cmd(0x38); //8位总线,双行显示,5X7点阵字符
write_cmd(0x0c); //打开显示屏,不显示光标,光标所在位置不闪烁 write_cmd(0x06); //写入数据后,地址自动加一
write_cmd(0x01); //清屏 delay(50);}