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

📄 clocktime.lst

📁 以C8051F020单片机做的多功能计数器
💻 LST
字号:
C51 COMPILER V7.50   CLOCKTIME                                                             09/20/2008 15:21:11 PAGE 1   


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

line level    source

   1          #include "clocktime.h"
   2          
   3          xdata float tempdata,temph,templ;
   4          char dh,dl;
   5          unsigned char tempvalue;
   6          
   7          
   8          void ShowDateTime()
   9          {
  10   1              xdata char  str[14];
  11   1              xdata char  readout[7];
  12   1              unsigned char  i=0;
  13   1      
  14   1              //读时钟
  15   1              v_Get1302(readout);
  16   1      
  17   1              for(i=0;i<7;i++)
  18   1                      readout[i]=BCD_TO_HEX(readout[i]);
  19   1              strcpy(str,"20");
  20   1              strcat(str,IntToStr(readout[6],0,2));
  21   1              strcat(str,"年");
  22   1              strcat(str,IntToStr(readout[4],0,2));
  23   1              strcat(str,"月");
  24   1              strcat(str,IntToStr(readout[3],0,2));
  25   1              strcat(str,"日");
  26   1              LcdShow(0,1,str);
  27   1      
  28   1                      //显示星期
  29   1                      str[0]=0xd0;
  30   1                      str[1]=0xc7;
  31   1                      str[2]=0xc6;
  32   1                      str[3]=0xda;
  33   1                      switch(readout[5])
  34   1                      {
  35   2                      case 0x01:
  36   2                              str[4]=0xd2;
  37   2                              str[5]=0xbb;
  38   2                              break;
  39   2                      case 0x02:
  40   2                              str[4]=0xb6;
  41   2                              str[5]=0xfe;
  42   2                              break;
  43   2                      case 0x03:
  44   2                              str[4]=0xc8;
  45   2                              str[5]=0xfd;
  46   2                              break;
  47   2                      case 0x04:
  48   2                              str[4]=0xcb;
  49   2                              str[5]=0xc4;
  50   2                              break;
  51   2                      case 0x05:
  52   2                              str[4]=0xce;
  53   2                              str[5]=0xe5;
  54   2                              break;
  55   2                      case 0x06:
C51 COMPILER V7.50   CLOCKTIME                                                             09/20/2008 15:21:11 PAGE 2   

  56   2                              str[4]=0xc1;
  57   2                              str[5]=0xf9;
  58   2                              break;
  59   2                      case 0x07:
  60   2                              str[4]=0xcc;
  61   2                              str[5]=0xec;
  62   2                              break;
  63   2                      }
  64   1              str[6]=0;
  65   1              LcdShow(1,1,str);       
  66   1              //显示温度
  67   1              ShowTemp();
  68   1              //显示时间
  69   1              strcpy(str,"");
  70   1              strcat(str,IntToStr(readout[2],1,2));
  71   1              strcat(str,":");
  72   1              strcat(str,IntToStr(readout[1],0,2));
  73   1              strcat(str,":");
  74   1              strcat(str,IntToStr(readout[0],0,2));
  75   1              LcdShow(2,2,str);
  76   1              LcdShow(3,1,"请选择测试功能");
  77   1      }
  78          
  79          void ShowTime() 
  80          {
  81   1              xdata char  str[14];
  82   1              xdata char  readout[7];
  83   1              unsigned char  i=0;
  84   1      
  85   1      //      start1302();
  86   1              //读时钟
  87   1              v_Get1302(readout);
  88   1      
  89   1              for(i=0;i<7;i++)
  90   1                      readout[i]=BCD_TO_HEX(readout[i]);
  91   1              strcpy(str,"");
  92   1              strcat(str,IntToStr(readout[2],1,2));
  93   1              strcat(str,":");
  94   1              strcat(str,IntToStr(readout[1],0,2));
  95   1              strcat(str,":");
  96   1              strcat(str,IntToStr(readout[0],0,2));
  97   1              LcdShow(2,2,str);
  98   1      }
  99          
 100          
 101          
 102          //called when reading time,if the data read from DS1302 is 49(0x31),the time should be BCD_TO_HEX(49)=31(0
             -x1f)
 103          unsigned char BCD_TO_HEX(unsigned char bcd_data)    //hex转为bcd子程序 
 104          {
 105   1              return (bcd_data/16*10+bcd_data%16);
 106   1      }
 107          
 108          /*
 109          //called when seting time,if you want to set the time as 31 seconds,just write  HEX_TO_BCD(31) to DS1302
 110          unsigned char HEX_TO_BCD(unsigned char hex_data)    //BCD转为HEX子程序  
 111          {
 112                  return (hex_data/10*16+hex_data%10);
 113          }
 114          */
 115          
 116          void ShowTemp()
C51 COMPILER V7.50   CLOCKTIME                                                             09/20/2008 15:21:11 PAGE 3   

 117          {
 118   1      //      LcdShow(1,5,"28℃");    
 119   1      
 120   1        char str[4];
 121   1        tempint=0;
 122   1        tempbusy=1;
 123   1        while(tempint==0){}
 124   1        tempbusy=0;
 125   1        if(tempint==1)
 126   1        {
 127   2                 templ=ADC0L;
 128   2                 temph=ADC0H&0x0f;
 129   2                 tempdata=temph*256+templ;
 130   2                 tempvalue=(unsigned char)(((tempdata/4095)*2.4-0.776)/0.00286);
 131   2                 strcpy(str,"");
 132   2                 strcat(str,IntToStr(tempvalue,1,2));
 133   2                 strcat(str,"℃");
 134   2                 LcdShow(1,5,str);
 135   2         }
 136   1         
 137   1      }
 138          /*
 139          void ShowDateTime()
 140          {
 141                  LcdShow(0,0,"2008年09月12日");
 142                  LcdShow(1,0,"星期五11:20:32");
 143                  LcdShow(2,2,"28摄氏度");
 144                  LcdShow(3,0,"请选择测试功能");
 145          }
 146          */
 147          
 148          
 149          
 150          void setDateTime()
 151          {
 152   1              xdata char pSecDa[7];   
 153   1              pSecDa[0]=0x00;
 154   1              pSecDa[1]=0x14;
 155   1              pSecDa[2]=0x15;
 156   1              pSecDa[3]=0x20;
 157   1              pSecDa[4]=0x09;
 158   1              pSecDa[5]=6;
 159   1              pSecDa[6]=8;
 160   1              v_Set1302(pSecDa);
 161   1      }
 162          
 163          
 164          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1060    ----
   CONSTANT SIZE    =     33    ----
   XDATA SIZE       =     12      49
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      3       6
   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 + -