缘由怎么用二个数码管做分的倒计时,DP亮灭来计秒,求思路 - 24小时必答区
#include "REG52.h"
sbit K1 = P1^5;
sbit K2 = P1^6;
sbit K3 = P1^7;
sbit BUZ1=P1^0;
bit k=0;
unsigned char code SmZiFu[]={63,6,91,79,102,109,125,7,127,111,128};//0-9.
unsigned char Js=0,miao=0,fen=0;//中断计时
void smxs(unsigned char mz,unsigned char w,unsigned char d)
{
unsigned char Xd=0;
P0=255;
P0=255-(d==1?SmZiFu[mz]:(SmZiFu[mz]|128));//小数点闪烁
P2=w;
while(++Xd);
}
void JiShi(/*时间计算*/)
{
if(Js>=20){Js=0;k=~k;if(++miao>=60){miao=0;if(++fen>=60)fen=0;}}
}
void ZhongDuanSheZhi()
{
TH0+=0X4c;/*定时器赋初值,定时50ms触发中断,自动补偿方式*/
TL0+=0X00;
TMOD=0X01;
TR0=1;
ET0=1; //开启定时器
EA=1; //全局中断开关
}
void main()
{
unsigned char Xd=200,ss=0;
unsigned int wei=0;
ZhongDuanSheZhi();
while(1)
{
if(K1==0&&++Xd==0){++fen;miao+=10;while(K1==0)smxs(ss,1,1);Xd=200;}
smxs(fen/10%10,4,k?0:1);
smxs(fen%10,8,k?1:0);
JiShi();//一定要放在最后
}
}
void ZhongDuan() interrupt 1
{
++Js;
TH0+=0X4c;
TL0+=0X00;
}