lcd1602写数据0x41,显示乱码,仿真正常。可能什么问题?
/***********1602液晶静态显示**************/
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar j;
uchar k;
sbit LCD_EN=P2^5;
sbit LCD_RS=P2^3;
sbit LCD_RW=P2^4;
void delay_10us(uchar i)
{
unsigned char a;
for(j=i;j>0;j--)
{
for(a=3;a>0;a--);
}
}
void write_command(uchar com)
{
LCD_RS=0;
LCD_RW=0;
P0=com;
delay_10us(100);
LCD_EN=1;
delay_10us(100);
LCD_EN=0;
}
void write_data(uchar dat)
{
LCD_RS=1;
LCD_RW=0;
P0=dat;
delay_10us(100);
LCD_EN=1;
delay_10us(100);
LCD_EN=0;
}
void LCD_init()
{
LCD_EN=0;
write_command(0x3c); //设置显示模式
write_command(0x0f); //设置开/关及光标设置
write_command(0x06); //光标左右移动
write_command(0x01); //清屏,及数据指针清零
write_command(0x80); //数据指针地址
}
void main(void)
{
LCD_init();
write_data(0x41);
while(1);
}
|