在弄完程序(keil编译没有错误,没有警告),弄完电路图进行仿真的时候我的1602只亮就是不显示东西
这是小弟关于1602部分的函数,在小弟的设想当中是调用init1602函数后分别在显示屏上下两行显示HELLO DRIVER和Distance: 000CM
sbit RS = P3^5;
sbit RW = P3^6;
sbit EN = P3^4;
#define LCD_data P1
#define uchar unsigned char
#define uint unsigned int
void LCDdelay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=10;y>0;y--);
}
void write_com(uchar com)
{
RS=0;
P0=com;
LCDdelay(5);
EN=1;
LCDdelay(5);
EN=0;
}
void write_data(uchar date)
{
RS=1;
P0=date;
LCDdelay(5);
EN=1;
LCDdelay(5);
EN=0;
}
bit LCD_Check_Busy(void)
{
DataPort= 0xFF;
RS_CLR;
RW_SET;
EN_CLR;
_nop_();
EN_SET;
return (bit)(DataPort & 0x80);
}
void LCD_Write_String(uchar x,uchar y,uchar *s)
{
while(LCD_Check_Busy());
if (y == 0)
{
write_com(0x80 + x);
}
else
{
write_com(0xC0 + x);
}
while (*s)
{
write_data( *s);
s ++;
}
}
void Init1602()
{
uchar i=0;
write_com(0x38);
write_com(0x0C);
write_com(0x06);
write_com(0x01);
LCD_Write_String(1,0," HELLO DRIVER ");
LCD_Write_String(1,1,"Distance: 000CM");
}
|