标题: 单片机秒表proteus仿真及源码 [打印本页]

作者: 51黑ff    时间: 2016-9-28 13:27
标题: 单片机秒表proteus仿真及源码


源程序:
  1. #include<reg51.h>
  2. unsigned char t[3]={0,0,0},x[3];
  3. unsigned int a=4000;
  4. unsigned char i;
  5. main()
  6. {
  7. TMOD=0x02;
  8. TH0=0x06;
  9. TL0=0x06;
  10. IE=0x82;
  11. TR0=1;

  12. while(1);
  13. }
  14. timer0() interrupt 1
  15. {//自动重装初值,因此不需再装

  16. a--;
  17. if(a==0)
  18. {
  19.   a=4000;
  20.   t[2]=t[2]+1;
  21.   if(t[2]==60)
  22.   {
  23.    t[2]=0;
  24.     t[1]=t[1]+1;
  25.    if(t[1]==60)
  26.    {
  27.     t[1]=0;
  28.      t[0]=t[0]+1;
  29.    }
  30.   }
  31. }
  32. for(i=0;i<3;i++)
  33. {
  34. x[i]=((t[i]/10)<<4)|(t[i]%10);
  35. }
  36. P2=x[0];
  37. P1=x[1];
  38. P0=x[2];
  39. }
复制代码

秒表.zip

31.99 KB, 下载次数: 29, 下载积分: 黑币 -5


作者: kabuapor    时间: 2016-12-20 14:26
111213132132




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