|
源程序:
- #include<reg51.h>
- unsigned char t[3]={0,0,0},x[3];
- unsigned int a=4000;
- unsigned char i;
- main()
- {
- TMOD=0x02;
- TH0=0x06;
- TL0=0x06;
- IE=0x82;
- TR0=1;
- while(1);
- }
- timer0() interrupt 1
- {//自动重装初值,因此不需再装
- a--;
- if(a==0)
- {
- a=4000;
- t[2]=t[2]+1;
- if(t[2]==60)
- {
- t[2]=0;
- t[1]=t[1]+1;
- if(t[1]==60)
- {
- t[1]=0;
- t[0]=t[0]+1;
- }
- }
- }
- for(i=0;i<3;i++)
- {
- x[i]=((t[i]/10)<<4)|(t[i]%10);
- }
- P2=x[0];
- P1=x[1];
- P0=x[2];
- }
复制代码
|
-
-
秒表.zip
31.99 KB, 下载次数: 29, 下载积分: 黑币 -5
|