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

📄 main.lst

📁 基于8051和8279的数字时钟程序
💻 LST
字号:
C51 COMPILER V7.50   MAIN                                                                  01/16/2009 20:31:48 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: D:\学习软件\keil\C51\BIN\C51.EXE main.c ROM(COMPACT) BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include<8279setting.h>
   2          #include<reg52.h>
   3          #include<ABSACC.h>
   4          #include<clock.h>
   5          #include<memerycheck.h>
   6          #define uchar   unsigned char   
   7          #define uint    unsigned int
   8          uchar idata function=0,updata=1;//0-正常记时间   1-设定时间
   9          uchar idata clock_seting[6]={10,10,10,10,10,10};//装载当前时间和设定时间
  10          uchar idata clock_curent[6]={1,2,3,4,0,1};//装载当前时间和设定时间
  11          uchar idata postion=5;
  12          uchar idata half=0;
  13          
  14          void dispsettingtime(void);//显示时间
  15          void dispcurrenttime(void);//显示时间
  16          
  17          void operate(uchar key);//按键操作
  18          void inputtime(uchar key);//修改时间
  19          void cancel(void );//取消输入
  20          void sure(void);//确认输入
  21          
  22          main()
  23          {       
  24   1              init_8279();
  25   1              IE=0x00;/*关中断*/
  26   1              IT0=1;  /*选择负跳变触发*/
  27   1              TMOD=0X01;/*计数模式*/
  28   1              IP=0X02;  /*优先级*/
  29   1              TL0=0XAF;//初值0.05秒
  30   1              TH0=0X3C;
  31   1              SP=0X60;
  32   1              IE=0x83;/*开中断*/      
  33   1              TR0=1;
  34   1              while(1)
  35   1              {
  36   2                      if(updata==1)
  37   2                      {
  38   3                              add_second(clock_curent);
  39   3                              updata=0;
  40   3                              if(function==0)
  41   3                              dispcurrenttime();
  42   3                      }
  43   2              }
  44   1      
  45   1      }
  46          
  47          void service_second(void) interrupt 1 /*外部中断置标志*/
  48          { 
  49   1              TR0=0;          
  50   1              TL0=0XAF;
  51   1              TH0=0X3C;
  52   1              TR0=1;
  53   1              half++;
  54   1              if(half==20)
  55   1              {
C51 COMPILER V7.50   MAIN                                                                  01/16/2009 20:31:48 PAGE 2   

  56   2                      updata=1;
  57   2                      half=0;
  58   2              }
  59   1      }
  60          void service_int0(void) interrupt 0  /*外部中断置标志*/
  61          {
  62   1              uchar key;
  63   1              key=keyin_8279();
  64   1              operate(key);   
  65   1      }
  66          void operate(uchar key)//按键操作
  67          {
  68   1              switch(key)
  69   1              {
  70   2                      case 'a':       function=(++function)%2;
  71   2                                              if(function==1) 
  72   2                                                      dispsettingtime();
  73   2                                              else    
  74   2                                                      dispcurrenttime();
  75   2                                              break;
  76   2                      case 'b':       sure();         break;
  77   2                      case 'c':       cancel();       break;
  78   2                      case 'd':       break;
  79   2                      case 'e':       break;
  80   2                      case 'f':       break;
  81   2                      default :       if(function==1) inputtime(key);break;
  82   2              }
  83   1      }
  84          
  85          void sure(void)
  86          {       
  87   1              uchar i;
  88   1              if(function==1)
  89   1              {       postion++;
  90   2                      if(postion!=6)
  91   2                              {       
  92   3                                      i=0;
  93   3                                      while(i<postion)
  94   3                                      {clock_curent[i]=0;i++;}
  95   3                                      while(i<6)
  96   3                                      {clock_curent[i]=clock_seting[i];i++;}
  97   3                              }
  98   2                      for(i=0;i<6;i++)
  99   2                      clock_seting[i]=10;
 100   2                      postion=5;
 101   2                      function=0;
 102   2              }
 103   1      
 104   1                      
 105   1      }
 106          
 107          
 108          void cancel(void)
 109          {       
 110   1              uchar i;
 111   1              dispcurrenttime();      
 112   1              for(i=0;i<6;i++)
 113   1              clock_seting[i]=10;
 114   1              function=0;
 115   1      }       
 116          
 117          
C51 COMPILER V7.50   MAIN                                                                  01/16/2009 20:31:48 PAGE 3   

 118          void inputtime(uchar key)//修改时间
 119          {       
 120   1      
 121   1              switch(postion)
 122   1              {
 123   2                      case 5: if(key<=2)      
 124   2                                              {clock_seting[5]=key;postion--;}
 125   2                                      break;
 126   2                      case 4: if((clock_seting[5]==2)&&(key>4))
 127   2                                              ;
 128   2                                      else 
 129   2                                              {clock_seting[4]=key;postion--;}
 130   2                                      break;  
 131   2                      case 3:         
 132   2                      case 1:                 
 133   2                                      if(key<6)       
 134   2                                              {clock_seting[postion]=key;postion--;}
 135   2                                      break;
 136   2                      case 2:                 
 137   2                      case 0: clock_seting[postion]=key;      postion--;      
 138   2                                      break;
 139   2              }
 140   1              dispsettingtime();
 141   1      }
 142          
 143          
 144          
 145          void dispcurrenttime(void)//显示时间
 146          {       
 147   1              if(clock_curent[5]==0)
 148   1                      disp(7,11);     //首位0消隐
 149   1              else 
 150   1                      disp(7,clock_curent[5]);//小时
 151   1              disp(6,clock_curent[4]);
 152   1              disp(5,10);
 153   1              disp(4,clock_curent[3]);//分钟
 154   1              disp(3,clock_curent[2]);
 155   1              disp(2,10);
 156   1              disp(1,clock_curent[1]);//秒钟
 157   1              disp(0,clock_curent[0]);
 158   1      }
 159          
 160          void dispsettingtime(void)//显示时间
 161          {       
 162   1              disp(7,clock_seting[5]);
 163   1              disp(6,clock_seting[4]);
 164   1              disp(5,10);
 165   1              disp(4,clock_seting[3]);//分钟
 166   1              disp(3,clock_seting[2]);
 167   1              disp(2,10);
 168   1              disp(1,clock_seting[1]);//秒钟
 169   1              disp(0,clock_seting[0]);
 170   1      }
 171          
 172          
 173          
 174          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    523    ----
   CONSTANT SIZE    =   ----    ----
C51 COMPILER V7.50   MAIN                                                                  01/16/2009 20:31:48 PAGE 4   

   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       1
   IDATA SIZE       =     16    ----
   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 + -