为什么LCD不显示。。而且RS,RW,EN输出是高阻态。程序
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit rs=P2^1;
sbit rw=P1^5;
sbit en=P1^6;
void delay(uchar t)
{
uint x,y;
for(x=t;x>0;x--)
for(y=110;y>0;y--);
}
void write_cmd(uchar cmd)
{
rs=0;
rw=0;
P0=cmd;
delay(5);
en=1;
delay(5);
en=0;
}
void write_dat(uchar dat)
{
rs=1;
rw=0;
P0=dat;
delay(5);
en=1;
delay(5);
en=0;
}
void lcd_inter()
{
write_cmd(0x02);
write_cmd(0x06);
write_cmd(0xc0);
write_cmd(0x38);
write_cmd(0x01);
}
void main()
{
rw=0;
rs=0;
en=0;
lcd_inter();
write_cmd(0x80);
write_dat('1');
while(1);
}
|