为什么这个程序在proteus中可以显示,下载到单片机后就不能显示,大家看下怎么回事
#include<stc52.h>
# define uchar unsigned char
sbit RS=P3^5;
sbit RW=P3^6;
sbit E=P3^7;
void Delay5ms();
void write_com(uchar com);
void write_dat(uchar dat);
void init_lcd(void);
uchar x;
uchar code st1[]=" stady-hard";
uchar code st2[]=" ************";
void main()
{
init_lcd();
while(1)
{
for(x=0;x<13;x++)
{
write_dat(st1[x]);
}
write_com(0xc0);
for(x=0;x<14;x++)
{
write_dat(st2[x]);
}
while(1);
}
}
void init_lcd(void)
{
write_com(0x38); //éèÖÃÏÔê¾μãÕó
write_com(0x08);
write_com(0x01);
write_com(0x06); //1a±ê1éλ
write_com(0x0f); //¿aÏÔê¾1a±êéᣬ0x0c,ÎT1a±ê
}
void write_com(uchar com)
{
RS=0;
RW=0;
E=0;
P2=com;
E=1;
Delay5ms();
E=0;
}
void write_dat(uchar dat)
{
RS=1;
RW=0;
E=0;
P2=dat;
E=1;
Delay5ms();
E=0;
}
void Delay5ms() //@11.0592MHz
{
unsigned char i, j;
i = 9;
j = 244;
do
{
while (--j);
} while (--i);
}
|