⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shizhong.lst

📁 基于AT89C51单片机实现的电子时钟
💻 LST
字号:
C51 COMPILER V8.08   SHIZHONG                                                              05/20/2009 16:35:09 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE SHIZHONG
OBJECT MODULE PLACED IN SHIZHONG.OBJ
COMPILER INVOKED BY: E:\Program Files\keil\C51\BIN\C51.EXE SHIZHONG.C BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <reg52.h>
   2          #define  uchar unsigned char
   3          #define  uint  unsigned int
   4          uint getemp=0,shitemp=0 ;
   5          unsigned long int   temp0=0,temp1=0;
   6          uchar code duan[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
   7          uchar code wei[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
   8          unsigned long int  time=41235;
   9          uchar con=0 ,AA=0 ;
  10          
  11          
  12          sbit key1=P1^0;
  13          sbit key2=P1^1;
  14          sbit key3=P1^2;
  15          
  16          /////*****使用函数************///////
  17          void delay( uint t) ;
  18          void clear ( void ) ;
  19          void disp(void ) ;
  20          void key( void ) ;
  21          ////**************************//////
  22          /*延时t*/
  23          void delay(uint t)
  24          {
  25   1        uint i,j;
  26   1        for (i=0;i<t;i++)
  27   1          for (j=0;j<120;j++)
  28   1                ;
  29   1      }
  30          ///*定时器初始化函数*///
  31          void clear ( void )
  32          {
  33   1      TMOD=0x01;
  34   1      EA=1;//开总中断
  35   1      ET0=1;//开定时器T0中断
  36   1      
  37   1      TH0 =(65535-50000)/256 ;
  38   1      TL0 =(65535-50000)%256 ;//对定时器T0赋初值
  39   1      TR0=1 ;//启动定时器T0开始计时
  40   1       }
  41          /*主函数*/
  42          main()
  43          {
  44   1       clear();
  45   1       while (1)
  46   1       {
  47   2        key() ;
  48   2        disp();
  49   2       }   
  50   1      }
  51          
  52          
  53          
  54          /*键扫描*/
  55          void key( void )
C51 COMPILER V8.08   SHIZHONG                                                              05/20/2009 16:35:09 PAGE 2   

  56          {
  57   1        if (AA== 4)
  58   1         {
  59   2          AA=0;
  60   2          ET0=1;
  61   2         }
  62   1      
  63   1       if(key1==0)
  64   1        delay(10);
  65   1       if(key1==0)
  66   1         {
  67   2           while (key1==0)   ;  // key 1  进入
  68   2           ET0=0;
  69   2           AA++ ;
  70   2          }
  71   1       if(key2==0)
  72   1         delay(10);
  73   1       if(key2==0)
  74   1         {
  75   2          while (key2==0)   ;   // key 2  进入
  76   2           if(AA==1) time =time + 1 ;
  77   2           if(AA==2) time =time +60 ;
  78   2           if(AA==3) time =time +3600;
  79   2          }
  80   1       if(key3==0)
  81   1         delay (10) ;
  82   1       if (key3==0)
  83   1         {
  84   2          while (key3==0)    ;   // key 3 进入
  85   2           if(AA==1) time =time - 1   ;
  86   2           if(AA==2) time =time - 60  ;
  87   2           if(AA==3) time =time - 3600;
  88   2          }
  89   1      
  90   1       } 
  91          
  92          /*显示 */
  93          void disp(void )
  94          {
  95   1        {temp0= time%60;
  96   2         getemp= temp0%10;
  97   2         shitemp= temp0/10;
  98   2         P0=duan[getemp];
  99   2         P2=wei[7];
 100   2         delay(1);
 101   2         P2=0x00;
 102   2         P0=duan[shitemp];
 103   2         P2=wei[6];
 104   2         delay(1);
 105   2         P2=0x00;
 106   2         }           //秒
 107   1      
 108   1         P0=0xbf;
 109   1         P2=wei[5];
 110   1         delay(1);
 111   1         P2=0x00;
 112   1                      //-
 113   1         {temp0=(time-time%60 )/60;
 114   2         temp0= temp0%60;
 115   2         getemp= temp0%10;
 116   2         shitemp= temp0/10;
 117   2         P0=duan[getemp];
C51 COMPILER V8.08   SHIZHONG                                                              05/20/2009 16:35:09 PAGE 3   

 118   2         P2=wei[4];
 119   2         delay(1);
 120   2         P2=0x00;
 121   2         P0=duan[shitemp];
 122   2         P2=wei[3];
 123   2         delay(1);
 124   2         P2=0x00;
 125   2         }            // 分
 126   1      
 127   1         P0=0xbf;
 128   1         P2=wei[2];
 129   1         delay(1);
 130   1         P2=0x00;     //  -
 131   1      
 132   1         {temp0= time/3600 ;
 133   2         getemp= temp0%10;
 134   2         shitemp= temp0/10;
 135   2         P0=duan[getemp];
 136   2         P2=wei[1];
 137   2         delay(1);
 138   2         P2=0x00;
 139   2         P0=duan[shitemp];
 140   2         P2=wei[0];
 141   2         delay(1);
 142   2         P2=0x00;
 143   2         }          // 时
 144   1      
 145   1      } 
 146          
 147          //*50ms定时器中断*//
 148          void time0 ( void ) interrupt  1 using  1
 149          {EA=0;
 150   1       TH0= (65535-50000)/256 ;
 151   1       TL0= (65535-50000)%256 ;
 152   1       con++;
 153   1       while ( con==5 ) 
 154   1       {
 155   2         con=0;
 156   2        if(time<86400)
 157   2         time ++ ;
 158   2        else
 159   2         time =0 ;
 160   2        }  
 161   1      
 162   1       EA=1;
 163   1      }
 164          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    797    ----
   CONSTANT SIZE    =     18    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     18    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -