标题: 基于51单片机的60秒,秒表计时器 [打印本页]

作者: LIVEQ    时间: 2017-11-27 13:05
标题: 基于51单片机的60秒,秒表计时器
keil软件生成HEX文件,在proteus仿真实现
C程序
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
uchar code num[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uint i,c;
sbit ret=P3^0;
void main ()
{           i=0;c=0;
            TMOD=0x10;
            ET1=1;
            EA=1;
           TR1=1;
           TH1=(65536-5000)/256;
           TL1=(65536-5000)%256;
      P0=num[0];P2=num[0];P1=num[0];
      
           while(ret==0){
                          while(1)
                                 {
                  if(ret==0){EA=0;}
                  else
                     { EA=1;
                                       if(c==20){c=0;i++;}
                                       if(i<600){P0=num[i/100];P2=num[i%100/10];P1=num[i%10];}
                    else i=0;
                                      }
                 }     
             }
}
void timer1 () interrupt 3
{           TH1=(65536-5000)/256;
           TL1=(65536-5000)%256;
      c++;
}

1.jpg (119.86 KB, 下载次数: 165)

proteus仿真实现

proteus仿真实现

作者: 4944844    时间: 2021-10-24 07:05
不行呢,只出现两位数用的这种#include <stc15f2k60s2.h>




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1