请问各位大神,为啥将这个程序导入单片机1602显示屏上不显示呢??
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]="I LOVE MCU!";
uchar code table1[]="wo de ni!!!";
sbit RS = P2^4; //定义端口
sbit RW = P2^5;
sbit EN = P2^6;
uchar num;
void delay(uint x) //延时1ms
{
uint i,j;
for(i=x;i>=0;i--)
for(j=100;j>=0;j--);
}
void write_com(uchar com)//写入命令字操作
{
RS=0;
RW=0;
P0=com;
delay(5);
EN=1;
delay(5);
EN=0;
}
void write_data(uchar date)//写入数据字操作
{
RS=1;
RW=0;
P0=date;
delay(5);
EN=1;
delay(5);
EN=0;
}
void init()//1602显示屏初始化
{
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}
void main()
{
init();
write_com(0x80);
for(num=0;num<11;num++)
{
write_data(table[num]);
delay(10);
}
write_com(0x80+0x40);
for(num=0;num<11;num++)
{
write_data(table1[num]);
delay(10);
}
while(1);
}
|