12864 同一行同时显示中英文会乱码
怎么解决?第三行跟第四行有文字是重复的,但是第四行显示正常,第三行显示乱码,第三行是中英文都有的。采纳加分#include<reg52.h>#defineDBP0sbit...
怎么解决?第三行跟第四行有文字是重复的,但是第四行显示正常,第三行显示乱码,第三行是中英文都有的。采纳加分
#include<reg52.h>
#define DB P0
sbit RS=P2^0;
sbit RW=P2^1;
sbit E=P2^2;
sbit BF=P0^7;
sbit Key=P3^0;
char line1[]="LCM test program";
char line2[]="Everything is OK";
char line3[]="中文LCD使用测试";
char line4[]="一切正常欢迎使用";
void write_inst(char inst);
void write_char(char chardata);
void init_LCM();
void check_BF();
void delay(unsigned int x);
int main()
{
unsigned char i;
init_LCM();
write_inst(0x80);
for(i=0;i<16;i++)
{
write_char(line1[i]);
}
write_inst(0x90);
for(i=0;i<16;i++)
{
write_char(line2[i]);
}
write_inst(0x88);
for(i=0;i<16;i++)
{
write_char(line3[i]);
}
write_inst(0x98);
for(i=0;i<16;i++)
{
write_char(line4[i]);
}
write_inst(0x9f);
while(1)
{
if(Key==0)
{
delay(200);
write_inst(0x14);
}
}
}
void write_inst(char inst)
{
check_BF();
RS=0;
RW=0;
E=1;
DB=inst;
check_BF();
}
void write_char(char chardata)
{
check_BF();
DB=chardata;
RS=1;
RW=0;
E=1;
check_BF();
}
void init_LCM()
{
write_inst(0x30);
write_inst(0x30);
write_inst(0x08);
write_inst(0x01);
write_inst(0x06);
write_inst(0x0f);
}
void check_BF()
{
E=0;
do
{
BF=1;
RS=0;
RW=1;
E=1;
}while(BF==1);
}
void delay(unsigned int x)
{
unsigned int j,y;
for(j=0;j<x;j++)
{
for(y=0;y<120;y++);
}
} 展开
#include<reg52.h>
#define DB P0
sbit RS=P2^0;
sbit RW=P2^1;
sbit E=P2^2;
sbit BF=P0^7;
sbit Key=P3^0;
char line1[]="LCM test program";
char line2[]="Everything is OK";
char line3[]="中文LCD使用测试";
char line4[]="一切正常欢迎使用";
void write_inst(char inst);
void write_char(char chardata);
void init_LCM();
void check_BF();
void delay(unsigned int x);
int main()
{
unsigned char i;
init_LCM();
write_inst(0x80);
for(i=0;i<16;i++)
{
write_char(line1[i]);
}
write_inst(0x90);
for(i=0;i<16;i++)
{
write_char(line2[i]);
}
write_inst(0x88);
for(i=0;i<16;i++)
{
write_char(line3[i]);
}
write_inst(0x98);
for(i=0;i<16;i++)
{
write_char(line4[i]);
}
write_inst(0x9f);
while(1)
{
if(Key==0)
{
delay(200);
write_inst(0x14);
}
}
}
void write_inst(char inst)
{
check_BF();
RS=0;
RW=0;
E=1;
DB=inst;
check_BF();
}
void write_char(char chardata)
{
check_BF();
DB=chardata;
RS=1;
RW=0;
E=1;
check_BF();
}
void init_LCM()
{
write_inst(0x30);
write_inst(0x30);
write_inst(0x08);
write_inst(0x01);
write_inst(0x06);
write_inst(0x0f);
}
void check_BF()
{
E=0;
do
{
BF=1;
RS=0;
RW=1;
E=1;
}while(BF==1);
}
void delay(unsigned int x)
{
unsigned int j,y;
for(j=0;j<x;j++)
{
for(y=0;y<120;y++);
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询