|
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
uint m;//下降沿次數(shù)
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){ //寫數(shù)據(jù)
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 //定時(shí)計(jì)數(shù)器0溢出中斷服務(wù)程序
{
m++; //溢出次數(shù)加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);
}
我想實(shí)現(xiàn)的是有脈沖下降沿就顯示次數(shù),仿真卻顯示第一行第一個(gè)光標(biāo)位置跳動(dòng)
|
-
11.jpg
(145.64 KB, 下載次數(shù): 52)
下載附件
2018-5-5 13:34 上傳
|