新出课设题目。我就在网上找了个
电路图。
然后就遇到程序问题。
#include<reg52.h>
#include<intrins.h>
sbit RS=P2^0;
sbit RW=P2^1;
sbit E=P2^2;
sbit BF=P1^7;
char world[]="Welcome!";
char world1[]="Good morning!";
void delay1ms()
{
unsigned char i,j;
for(i=0;i<10;i++)
for(j=0;j<33;j++);
}
void delay(unsigned char n)
{
unsigned char i;
for(i=0;i<n;i++)
delay1ms();
}
void nop(unsigned s)
{
unsigned char i;
for(i=0;i<s;i++)
_nop_();
}
//Test the LCD is busing(1) of not(0)
unsigned char busytest(void)
{
bit result;
RS=0;
RW=1;
E=1;
nop(4);
result=BF;
E=0;
return result;
}
//Wri
ting the control world
void writecontrol(unsigned condata)
{
while(busytest()==1);
RS=0;
RW=0;
E=0;
nop(2);
P1=condata;
nop(4);
E=1;
nop(4);
E=0;
}
//Writing the data
void writedata(unsigned d)
{
while(busytest()==1);
RS=1;
RW=0;
E=0;
P1=d;
nop(4);
E=1;
nop(4);
E=0;
}
void lcdinit(void)
{
delay(15);
writecontrol(0x38);//8 bit;16*2;5*7
delay(5);
writecontrol(0x38);
delay(5);
writecontrol(0x38);
delay(5);
writecontrol(0x0f);//
显示开,有光标,光标闪烁
delay(5);
writecontrol(0x06);//
光标右移,字符不移
delay(5);
writecontrol(0x01);//
清屏
delay(5);
}
void main()
{
unsigned char i;
lcdinit();
delay(10);
while(1)
{
writecontrol(0x01);
writecontrol(0x80);//
第一行地址
i=0;
while(world
!=' ')
{
writedata(world);
i++;
delay(150);
}
for(i=0;i<4;i++)
delay(250);
writecontrol(0xc0);//
第二行地址
i=0;
while(world1!=' ')
{
writedata(world1);
i++;
delay(150);
}
for(i=0;i<4;i++)
delay(250);
}
}
我用的WAVE 600
就出现这个错误。。。求大神指点啊。。。求程序~~~
那大神帮帮忙被~~
一周热门 更多>