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

📄 main.lst

📁 51做的迷你数字钟
💻 LST
字号:
C51 COMPILER V7.06   MAIN                                                                  08/18/2008 11:08:39 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include<reg51.h>
   2          #include "time_ds1302_51.h"
   3          #define uchar unsigned char 
   4          #define uint  unsigned int 
   5          
   6          sbit DS = P2^3;
   7          sbit OE = P2^4;
   8          sbit RCK = P2^5;
   9          sbit SCK = P2^6;
  10          sbit SCLR = P2^7;
  11          
  12          sbit Key1 = P1^0;
  13          sbit Key2 = P1^1;
  14          sbit Sel17 = P1^2;
  15          sbit Sel18 = P1^3;
  16          void Send_data(uint DAT);
  17          code uint LED17[4][10]={
  18          {0,0,0x06,0,0,0,0,0,0,0},
  19          {0x68,0,0x38,0x30,0x50,0x70,0x78,0,0x78,0x70},
  20          {0x380,0x300,0x180,0x380,0x300,0x280,0x280,0x380,0x380,0x380},
  21          {0x3400,0,0x1c00,0x1800,0x2800,0x3800,0x3c00,0,0x3c00,0x3800},
  22          };
  23          code uint LED18[4][10]={
  24          {0,0x0c,0x06,0,0,0,0,0,0,0},
  25          {0x70,0x30,0x50,0x70,0x30,0x60,0x60,0x70,0x70,0x70},
  26          {0x680,0,0x700,0x300,0x180,0x380,0x780,0,0x780,0x380},
  27          {0x3800,0x1800,0x2800,0x3800,0x1800,0x3000,0x3000,0x3800,0x3800,0x3800},
  28          
  29          };
  30          
  31          uchar Time_get[7]={0x02,0x15,0x16,0x17,0x08,0x01,0x08};
  32          uchar Time_set[7]={0x02,0x15,0x16,0x17,0x08,0x01,0x08};
  33          uint Led17ram = 0x0000;
  34          uint Led18ram = 0x0000;
  35          
  36          void delay(uint t)
  37          {
  38   1              while(t--);
  39   1      }
  40          //功能:595传送数据函数
  41          //参数:整型数据,高位在前,低位在后
  42          void Send_data(uint DAT)
  43          {
  44   1              uchar i;
  45   1              SCLR = 0;
  46   1              SCLR = 1;
  47   1              SCK = 0;
  48   1              for(i = 16;i > 0;i--)
  49   1              {
  50   2                      SCK = 0;
  51   2                      if(DAT & (1 << (i-1)))
  52   2                              DS = 1;
  53   2                      else
  54   2                              DS = 0;
  55   2                      SCK = 1;
C51 COMPILER V7.06   MAIN                                                                  08/18/2008 11:08:39 PAGE 2   

  56   2                      
  57   2              }
  58   1              OE = 1;
  59   1              RCK = 1;
  60   1              RCK = 0;
  61   1              OE = 0;
  62   1      }
  63          
  64          void display(uchar t)
  65          {
  66   1              
  67   1              
  68   1              Send_data(Led17ram);
  69   1              Sel17 = 0;
  70   1              delay(t);
  71   1              Sel17 = 1;
  72   1              Send_data(Led18ram);
  73   1              Sel18 = 0;
  74   1              delay(t);
  75   1              Sel18 = 1;
  76   1      }
  77          
  78          void change_dis(uchar LED_left,uchar LED_right)
  79          {
  80   1              Led17ram &= 0xc001;
  81   1              Led18ram &= 0xc001;
  82   1      
  83   1              Led17ram |= LED17[0][LED_left/16]+LED17[1][LED_left%16]+LED17[2][LED_right/16]+LED17[3][LED_right%16];
  84   1              Led18ram |= LED18[0][LED_left/16]+LED18[1][LED_left%16]+LED18[2][LED_right/16]+LED18[3][LED_right%16];
  85   1      }
  86          
  87          uchar Key_scan(void)
  88          {
  89   1              if(Key1==0)
  90   1              {
  91   2                      return 1;
  92   2              }       
  93   1              else if(Key2==0)
  94   1              {
  95   2                      return 2;
  96   2              }
  97   1              else
  98   1                      return 0;
  99   1      }
 100          
 101          /*
 102          void initTimer(void)
 103          {
 104           TMOD=0x1;
 105           TH0=0xb1;
 106           TL0=0xe0;
 107          }
 108          
 109          void timer0(void) interrupt 1
 110          {
 111           
 112          
 113          TH0=0xb1;
 114           TL0=0xe0;
 115           
 116           //add your code here.
 117          
C51 COMPILER V7.06   MAIN                                                                  08/18/2008 11:08:39 PAGE 3   

 118          }
 119          */
 120          void main(void)
 121          {
 122   1              uint count=0;
 123   1              uint count1 = 50000;
 124   1              uchar count2 = 50;
 125   1              uint count3=0;
 126   1              uchar temp;
 127   1              uchar a=0;
 128   1              /*initTimer();
 129   1              TR0=1;
 130   1              ET0=1;*/
 131   1              init_ds1302();
 132   1              //Set1302(Time_set);
 133   1              
 134   1              //EA = 1;
 135   1              while(1)
 136   1              {
 137   2                      display(100);
 138   2                      count ++;
 139   2                      
 140   2                      if(count>110)
 141   2                      {
 142   3                              count = 0;
 143   3                              count2++;
 144   3                              if(count2>50)
 145   3                              {
 146   4                              count2=0;
 147   4                              Get1302(Time_get);
 148   4                              change_dis(Time_get[2],Time_get[1]);
 149   4                              }
 150   3                              
 151   3                              Led17ram ^= 0x4000;
 152   3                              if(Key_scan() != 0)
 153   3                              {
 154   4                                      count1 = 500;
 155   4                                      while(count1--)
 156   4                                      {
 157   5                                              display(100);
 158   5                                              
 159   5                                              if(Key_scan() == 1)
 160   5                                              {
 161   6                                                      count1 = 550;
 162   6                                                      temp = (Time_get[2]/16)*10+Time_get[2]%16;
 163   6                                                      count3++;
 164   6                                                      if(count3>50)
 165   6                                                      {
 166   7                                                              temp++;
 167   7                                                              count3=0;
 168   7                                                      }
 169   6                                                      
 170   6                                                      if(temp > 23)
 171   6                                                              temp = 0;
 172   6                                                      Time_get[2] = (temp/10)*16+temp%10;
 173   6                                                      Set1302(Time_get);
 174   6                                                      change_dis(Time_get[2],Time_get[1]);
 175   6                                              }
 176   5                                              else if(Key_scan() == 2)
 177   5                                              {
 178   6                                                      count1 = 550;
 179   6                                                      temp = (Time_get[1]/16)*10+Time_get[1]%16;
C51 COMPILER V7.06   MAIN                                                                  08/18/2008 11:08:39 PAGE 4   

 180   6                                                      count3++;
 181   6                                                      if(count3>10)
 182   6                                                      {
 183   7                                                              temp++;
 184   7                                                              count3=0;
 185   7                                                      }
 186   6                                                      
 187   6                                                      if(temp > 59)
 188   6                                                              temp = 0;
 189   6                                                      Time_get[1] = (temp/10)*16+temp%10;
 190   6                                                      Set1302(Time_get);
 191   6                                                      change_dis(Time_get[2],Time_get[1]);
 192   6                                              }
 193   5                                      }
 194   4                              }
 195   3                              else{;}
 196   3                      }
 197   2                      else{;}
 198   2                      
 199   2              }
 200   1      }
 201          
 202          
 203          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    657    ----
   CONSTANT SIZE    =    160    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     18       9
   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 + -