为什么多打几个汉字就错误呢?还有没有别的方法?
时间:10-02
整理:3721RD
点击:
#include<reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit e=P1^2;
sbit rs=P1^0;
sbit rw=P1^1;
sbit zhishi=P3^7;
uchar table[]= "亚太宣言";
uchar table1[]="能源形势十万火急";
uchar table2[]="国家安危发展大计";
uchar table3[]="用户焦虑我的压力";
uchar table4[]="化解危机依靠科技";
uchar table5[]="技术报国我心所系";
uchar table6[]="用户益我的课题";
uchar table7[]="好" ; //就这里再输入多一个汉字就编译出错了~为什么呢?难道只可48个汉字吗?
uchar table8[]= "就 ";
void write_com(uchar com1);
void write_data(uchar data1);
void xianshi(void);
void xianshi1(void);
void xianshi2(void);
void xianshi3(void);
void xianshi4(void);
void xianshi5(void);
void xianshi6(void);
void xianshi7(void);
void xianshi8(void);
void zs(void);
void init(void);
void delay(uint t)
{
uint j;
for(;t>0;t--)
for(j=20;j>0;j--);
}
void write_com(uchar com1)//写指令
{
rw=0;
rs=0;
delay(2);
P2=com1;
e=1;
delay(10);
e=0;
delay(10);
}
void write_data(uchar data1)//写数据
{
rw=0;
rs=1;
delay(2) ;
P2 = data1;
e=1;
delay(10);
e = 0;
delay(3) ;
}
void init(void)
{
delay(3); //等待
write_com(0x30); // 00110000
delay(5);
write_com(0x30);//
delay(5);
write_com(0x0c);//开显示光标e游标D反白c不显
delay(4);
write_com(0x01); // 清屏
delay(240);
write_com(0x10); // 移动
delay(10);
write_com(0x06);//
delay(10);
}
void xianshi(void)
{
uchar i;
write_com(0x82);
for (i=0;i<8;i++)
{
write_data(table);
delay(20);
}
}
void xianshi1(void)
{
uchar i;
write_com(0x90);
for (i=0;i<16;i++)
{
write_data(table1);
zs();
delay(200);
}
}
void xianshi8(void)
{
uchar i;
write_com(0x90);
for (i=0;i<16;i++)
{
write_data(table8);
zs();
delay(200);
}
}
void xianshi2(void)
{
uchar i;
write_com(0x88);
for (i=0;i<16;i++)
{
write_data(table2);
zs();
delay(200);
}
}
void xianshi7(void)
{
uchar i;
write_com(0x88);
for (i=0;i<16;i++)
{
write_data(table7);
zs();
delay(200);
}
}
void xianshi3(void)
{
uchar i;
write_com(0x98);
for (i=0;i<16;i++)
{
write_data(table3);
zs();
delay(200);
}
}
void zs(void) //工作指示灯
{
zhishi=0;
delay(2000);
zhishi=1;
delay(2000);
}
void xianshi4(void)
{
uchar i;
write_com(0x90);
for (i=0;i<16;i++)
{
write_data(table4);
zs();
delay(200);
}
}
void xianshi5(void)
{
uchar i;
write_com(0x88);
for (i=0;i<16;i++)
{
write_data(table5);
zs();
delay(20);
}
}
void xianshi6(void)
{
uchar i;
write_com(0x98);
for (i=0;i<16;i++)
{
write_data(table6);
zs();
delay(20);
}
}
void main(void)
{
init();
while(1)
{
xianshi (); //logo标志
xianshi1();
xianshi2();
xianshi3();
delay(4000);
delay(4000);
write_com(0x01); // 清屏
xianshi (); //logo标志
xianshi4();
xianshi5();
xianshi6();
delay(4000);
delay(4000);
write_com(0x01); // 清屏
xianshi (); //logo标志
xianshi7();
xianshi8();
delay(4000);
delay(4000);
write_com(0x01); // 清屏
}
}
能把错误贴出来看一下不
是不是编译后的数据太大,超出了单片机的空间
与数据类型有关系把
RAM空间不足吧,把那些汉字放在CODE里啊!