标题:
LCD模块显示,高手进~
[打印本页]
作者:
samwalton
时间:
2012-3-11 00:00
标题:
LCD模块显示,高手进~
用一个外部中断读取编码器圈数,用一个定时器实现30s倒计时,并将圈数和时间在LCD上显示。程序编译没有问题,但LCD上出现跳动的乱码,求高手帮帮忙呀~跪谢谢了~~ #include "lcd.h" #include "common.h" int degree=0; int time=35; int circle; unsigned char xdata countdown[2]; unsigned char xdata circlestr[2]; void main(void) { IT0=1; //外部中断0下降沿触发 EA=1; //全局中断打开 EX0=1; //允许外部中断0 TMOD|=0x01; //定时器0 16位定时器 X=65535-10000(10毫秒)=55535=D8F0(十六进制)定时10ms TH0=0xd8; //计数时间 TL0=0xf0; IE=0x82; //这里是中断优先级控制EA=1(开总中断),ET0=1(定时器0允许中断),这里用定时器0来定时 TR0=1; //打开定时器0 circle=degree/360; //取圈数 circlestr[0]=circle/10+0x30; //取十位 circlestr[1]=circle%10+0x30; //取个位 countdown[0]=time/10+0x30; //取时间十位 countdown[1]=time%10+0x30; //取个位 LCD_Init( ); LCD_ClearScreen(); while( 1 ) { LCD_ShowDot6x8Str(48, 1, circlestr); //LCD显示圈数 LCD_ShowDot6x8Str(48, 0, countdown); // LCD显示倒计时30s } } void int0()interrupt 0 //外部中断0 { EA=0; if(P3^3==0) degree++; else degree--; EA=1; } void tim(void) interrupt 1 using 1 //定时器0中断 { int count; //99只是一个数,可以任意改,因为这里只学习怎样实现倒计时 TH0=0xd8; //定时10毫秒 TL0=0xf0; count++; if(count==100) //10毫秒定时,10*100=1000(毫秒)=1秒 if(time>=0) time--; }
[此贴子已经被作者于2012-3-11 0:02:36编辑过]
作者:
fancommand
时间:
2012-3-11 10:29
怎么这么一塌糊涂? 如何看啊?
作者:
yanwo19840726
时间:
2012-3-16 14:36
lcd 清屏了吗
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1