找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

时钟怎么不走呀?

[复制链接]
admin 发表于 2012-9-2 10:41:46 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
不知道怎么的。时钟就是不走!我的程序:
#include <reg52.h>
#define uchar unsigned char
uchar cout0,cout1,k,i=0;
uchar miao=0;
uchar fen=0;
uchar shi=0;
uchar duanma[11]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x3f};
uchar weima[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar huancun[8];
void delay(uchar i)
{
do
{
huancun[0]=miao%10;
huancun[1]=miao/10;
huancun[2]=10;
huancun[3]=fen%10;
huancun[4]=fen/10;
huancun[5]=10;
huancun[6]=shi%10;
huancun[7]=shi/10;



}while(i--);
}
void timer1() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
if(++cout1==20)
{
cout1=0;
if(++miao==60)
{
miao=0;
if(++fen==60)
{
fen=0;
if(++shi==24)
shi=0;
}
}
}
}
void timer0() interrupt 1
{
if(++cout0==10)
{
cout0=0;
P2=weima[i];
P0=duanma[huancun[i]];
i++;
if(i==8) i=0;
}
}
unsigned char scankey()
{
unsigned char k;
P3=0x00;
P3=0xff;
k=P3&0xff;
if(k==0xff) return 0xff;
else if(k==0xfe) return 1;
else if(k==0xfd) return 2;
else if(k==0xfb) return 3;
else if(k==0xf7) return 4;
else if(k==0xef) return 5;
else if(k==0xdf) return 6;
else if(k==0xbf) return 7;
else if(k==0x7f) return 8;

}
void songjian()
{
uchar k;
while(1)
{
k=scankey();
if(k==scankey()&&k==0xff) break;
}

}
void main()
{
TMOD=0x12;
TH0=256-250;
TL0=256-250;
TR0=1;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TR1=1;
IE=0x8a;
while(1)
{
k=scankey();
delay(100);
if(k==scankey()&&k!=0xff)
{
songjian();
if(k==1)
{
TR1=0;
while(1)
{
k=scankey();
delay(100);
if(k==scankey()&&k!=0xff)
{
songjian();
if(k!=1)
{
switch(k)
{
case 3:miao++;
if(miao==60) miao=0;
break;
case 4:miao--;
if(miao==0xff) miao=59;
break;
case 5:fen++;
if(fen==60) fen=0;
break;
case 6:fen--;
if(fen==0xff) fen=59;
break;
case 7:shi++;
if(shi==24) shi=0;
break;
case 8:shi--;
if(shi==0xff) shi=23;
break;



}
}
if(k==2) {TR1=1;break;}
}

}

}
}
}
}
麻烦大神帮忙,小弟不胜感谢!
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-24 17:56 , Processed in 0.056773 second(s), 10 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表