10秒的秒表程序,带暂停
unsigned char code seg7[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}//数码管码表
unsigned char code tab[]={0xfe,0xfd}; //数码管位选
unsigned char cnt=0;//位选变量
unsigned char deta=0,sec=0; //0.01秒变量,和秒变量
sbit stop=P3^3; //暂停键
void init() //定时初始化
{
TMOD=0x11;
TH1=0xd8;
TL1=0xf0;
TR1=1;
TH0=0xfc;
TL0=0x18;
TR0=1;
ET1=1;
ET0=1;
EA=1;
}
void time10ms()interrupt 3
{
TH1=0xd8;
TL1=0xf0;
deta++;
}
void show()interrupt 1 //扫描显示2位adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=17&is_app=0&jk=f63b6e57c5e8b407&k=%CA%FD%C2%EB%B9%DC&k0=%CA%FD%C2%EB%B9%DC&kdi0=0&luki=2&n=10&p=baidu&q=98059059_cpr&rb=0&rs=1&seller_id=1&sid=7b4e8c5576e3bf6&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1831118&u=http%3A%2F%2Fwww%2E51hei%2Ecom%2Fmcu%2F2184%2Ehtml&urlid=0" id="0_nwl" mpid="0" target="_blank">数码管
{
TH0=0xfc;
TL0=0x18;
++cnt;
if(cnt>1)cnt=0;
switch (cnt)
{
case 0: P0=seg7[sec%10];P2=tab[0];break;
case 1: P0=seg7[sec/10];P2=tab[1];break;
default:break;
}
}
void showtime() //时间显示
{
if((deta>10)&&stop){sec++;deta=0;} //如果P3^3不按下,则为高电平,不暂停时间。
if(sec==99)sec=0;
}
void main()
{
init();
while(1)
{
showtime();
}
}
秒表程序暂 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)