完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
本人是单片机初学者,刚刚写了一个简单的1602lcd右移程序,但是错误的,想知道为什么这样编译无法执行,求大神告知,谢谢! 错误的点应该是在while(1)这里和中断 #include unsigned char THOR=0; unsigned char TLOR=0; #define Lcd P0 ***it LcdRS=P2^6; ***it LcdRW=P2^5; ***it LcdE=P2^7; unsigned char run; unsigned char str[]="Fighting"; void Dingshi(unsigned char ms); void Chushihua(); void Weizhixianshi(unsigned char x,unsigned char y,unsigned char *str); void main() { unsigned char a=0; //不加中断的话把主函数改为Chushihua(); Weizhixianshi(2,0,str); while(1);可以显示// EA=1; Dingshi(2); Chushihua(); while(1) //有问题,把Chushihua()或者Weizhixianshi()放在 // while()后面就出现问题,实现不了右移或者左移的效果,把初始化函数中的 0x06改为0x07也没反应。 if(run){ { run=0; Weizhixianshi(a++,0,str); if(a==16) { a=0; } } } } void Waittime() { unsigned char Duqu=0; Lcd=0xff; LcdRS=0; LcdRW=1; do { LcdE=1; Duqu=Lcd; LcdE=0; }while(Duqu & 0x80); } void Writemingling(unsigned char Zhiling) { Waittime(); LcdRS =0; LcdRW=0; LcdE=1; Lcd=Zhiling; LcdE=0; } void Writeshuju(unsigned char Zifu) { Waittime(); LcdRS =1; LcdRW=0; LcdE=1; Lcd=Zifu; LcdE=0; } void Weizhi(unsigned char x,unsigned char y) { if(y==0) { Writemingling((0x00+x)|0x80); } else Writemingling((0x40+x)|0x80); } void Weizhixianshi(unsigned char x,unsigned char y,unsigned char *str) { Weizhi(x,y); while(*str!=' |