|
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
uint m;//下降沿次数
uint a[]={1,2,3,4,5,6,7,8,9,0};
sbit RS=P2^0;
sbit RW=P2^1;
sbit EN=P2^2;
void delay(uint x){
uint i;
for(i = x;i>0;i--);
}
void writecom(uchar com){ //写指令
P0=com;
RS=0;RW=0;EN=1;
delay(200);
EN=0;
}
void writedat(uchar dat){ //写数据
P0=dat;
RS=1;RW=0;EN=1;
delay(200);
EN=0;
}
void init(){ //初始化LCD
writecom(0x01);
writecom(0x38);
writecom(0x0f);
writecom(0x06);
}
void TIME0() interrupt 0 //定时计数器0溢出中断服务程序
{
m++; //溢出次数加1
}
void main(){
uchar i;
EA=1;
EX0=1;
IT0=1;
init();
a[9]=m%10;
a[8]=(m/10)%10;
a[6]=m%10;
a[5]=(m/10)%10;
a[4]=(m/100)%10;
a[3]=(m/1000)%10;
a[2]=(m/10000)%10;
writecom(0x80);
for(i=2;i>=9;i++)
{
writedat(a[i]);
delay(10);
}
while(1);
}
我想实现的是有脉冲下降沿就显示次数,仿真却显示第一行第一个光标位置跳动
|
|