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

📄 ds1302.lst

📁 万年日历设计
💻 LST
字号:
C51 COMPILER V7.06   DS1302                                                                07/15/2012 20:15:16 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE DS1302
OBJECT MODULE PLACED IN .\obj\ds1302.obj
COMPILER INVOKED BY: D:\单片机相关软件\51单片机软件大全\Keil uVision2 软件\安装\C51\BIN\C51.EXE ds1302.c BROWSE DEBUG OB
                    -JECTEXTEND OBJECT(.\obj\ds1302.obj)

stmt level    source

   1          #include"init.h"
   2          #include"delay.h"
   3          #include"ds1302.h"
   4          /**********************************************************
   5                          
   6                                            //开始时的定义
   7          
   8          **********************************************************/
   9          void condition()    
  10          {
  11   1              RST=0;
  12   1              SCK=0;
  13   1              RST=1;
  14   1      }
  15          /**********************************************************
  16                          
  17                                           //发送一个字节
  18          
  19          **********************************************************/
  20          void sendbyte(uchar command,uchar dat) 
  21          {
  22   1              uchar i;
  23   1              condition();
  24   1              for(i=0;i<8;i++)
  25   1              {
  26   2                      SDA=command&0x01;
  27   2                      SCK=0;
  28   2                      SCK=1;
  29   2                      command>>=1;    
  30   2              }
  31   1              for(i=0;i<8;i++)
  32   1              {
  33   2                      SDA=dat&0x01;
  34   2                      SCK=0;
  35   2                      SCK=1;
  36   2                      dat>>=1;
  37   2              }
  38   1              RST=0;
  39   1      }
  40          /**********************************************************
  41                          
  42                                            //读一个字节
  43          
  44          **********************************************************/
  45          uchar readbyte(uchar command)    
  46          {
  47   1              uchar i,dat=0;
  48   1              condition();
  49   1              for(i=0;i<8;i++)
  50   1              {
  51   2                      SDA=command&0x01;
  52   2                      SCK=0;
  53   2                      SCK=1;
  54   2                      command>>=1;
C51 COMPILER V7.06   DS1302                                                                07/15/2012 20:15:16 PAGE 2   

  55   2              }
  56   1              for(i=0;i<8;i++)
  57   1              {
  58   2                      SCK=1;
  59   2                      SCK=0;
  60   2                      if(SDA)
  61   2                              dat|=0x01<<i;
  62   2              }
  63   1              RST=0;
  64   1              return (dat);
  65   1      }
  66          /**********************************************************
  67                          
  68                                           //1时准许写入;0时为写保护
  69          
  70          **********************************************************/
  71          void kaiguan(bit dat)   
  72          {
  73   1              if(dat)
  74   1                      sendbyte(0x8e,0x00);
  75   1              else
  76   1                      sendbyte(0x8e,0x80);
  77   1      }
  78          /**********************************************************
  79                          
  80                                         ds1302初始化
  81          
  82          **********************************************************/
  83          void init_ds1302()
  84          {
  85   1              kaiguan(1);
  86   1              sendbyte(0x80,0x45);    // 将45写入秒寄存器;
  87   1              sendbyte(0x82,0x59);    // 将59写入分寄存器;
  88   1              sendbyte(0x84,0x23);    // 将23写入小时寄存器;
  89   1              sendbyte(0x86,0x31);    // 将31日写入日寄存器;
  90   1              sendbyte(0x88,0x12);    // 将12月写入月寄存器;
  91   1              sendbyte(0x8a,0x03);    // 将05星期写入寄存器;
  92   1              sendbyte(0x8c,0x11);    // 将12年写入年寄存器;
  93   1      }
  94          /**********************************************************
  95                          
  96                                         ds1302时钟读取
  97          
  98          **********************************************************/
  99          void clock_reda()
 100          {
 101   1              week  =readbyte(0x8b);   //读星期
 102   1              year  =readbyte(0x8d);   //读年
 103   1              mouth =readbyte(0x89);   //读月
 104   1              day   =readbyte(0x87);   //读日
 105   1              hour  =readbyte(0x85);   //读小时
 106   1              minute=readbyte(0x83);   //读分钟
 107   1              sec   =readbyte(0x81);   //读秒 
 108   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    221    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
C51 COMPILER V7.06   DS1302                                                                07/15/2012 20:15:16 PAGE 3   

   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----       1
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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