帮我看看啊!!路过的朋友,进来看看,不知道怎么会出现这样的问题,
#include<reg52.h>
#include<intrins.h>//移位指令
#define uchar unsigned char
sbit KEY0=P3^0;
sbit KEY1=P3^1;
sbit KEY2=P3^2;
sbit led=P3^7;
uchar miao,fen,shi;
uchar aa=0xfe;
uchar m,i=0,k,j;
int n;
uchar shuju[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x40};//0到9+消隐的
uchar disbuf[10]={0,0,11,0,0,11,0,0};
//
void delay(uchar n)
{
for(j=0;j<n;j++)
for(k=0;k<110;k++);
}
void key()
{
if(KEY0==0)
{
delay(10);
if(KEY0==0)
{
miao++;
if(miao==60)miao=0;
while(!KEY0);
}
}
if(KEY1==0)
{
delay(10);
if(KEY1==0)
{
fen++;
if(fen==60)fen=0;
while(!KEY1);
}
}
if(KEY2==0)
{
delay(10);
if(KEY2==0)
{
shi++;
if(shi==60)shi=0;
while(!KEY2);
}
}
}
void main()
{
TMOD=0X22;//定时器计数器T0工作方式2;
TL0=0X06;
TH0=0X06;
TL1=0x06;TH1=0x06;
ET1=1;
ET0=1;
EA=1;
TR0=1;
TR1=1;
while(1)
{key();}
}
void TO_time() interrupt 1
{
m++;
if(m==8)//2Ms扫描一次
{
m=0;
P1=shuju[disbuf[i]];
P2=aa;
aa=_crol_(aa,1);
i++;
if(i==8)
{i=0;}
}
}
void T1_time() interrupt 3
{
n++;
if(n==4000)
{
led=~led; //led1秒亮灭//
n=0;
miao++;
if(miao==60)
{
miao=0;
fen++;
if(fen==60)
{
fen=0;
shi++;
if(shi==24)
{shi=0;}
}
}
}
disbuf[0]=miao%10;
disbuf[1]=miao/10;
disbuf[3]=fen%10;
disbuf[4]=fen/10;
disbuf[6]=shi%10;
disbuf[7]=shi/10;
}
|