在弄完程序(keil編譯沒有錯誤,沒有警告),弄完電路圖進行仿真的時候我的1602只亮就是不顯示東西
仿真.PNG (46.87 KB, 下載次數: 34)
下載附件
仿真圖
2019-5-12 20:09 上傳
這是小弟關于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");
}
|