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

📄 ds1302.lst

📁 P/S 测试程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
A51 MACRO ASSEMBLER  DS1302                                                               11/04/2008 14:17:15 PAGE     1


MACRO ASSEMBLER A51 V7.00a
OBJECT MODULE PLACED IN DS1302.OBJ
ASSEMBLER INVOKED BY: d:\Keil\C51\BIN\A51.EXE DS1302.asm SET(SMALL) DEBUG EP

LOC  OBJ            LINE     SOURCE

                       1     ;
                       2     ;//*DS1302 PIN:
                       3     ;//*
                       4     ;//* SCLK (Serial Clock Input) - SCLK is used to synchronize data movement on
                       5     ;//* the serial interface. This pin has a 40k. internal pull-down resistor.
  0092                 6     p1302SCLK       BIT     P1.2
                       7     ;//* I/O (Data Input/Output) - The I/O pin is the bi-directional data pin for
                       8     ;//* the 3-wire interface. This pin has a 40k. internal pull-down resistor.
  0093                 9     p1302IO         BIT     P1.3
                      10     ;//* RST (Reset) - The reset signal must be asserted high during a read or a
                      11     ;//* write. This pin has a 40k.internal pull-down resistor.
  0094                12     p1302RST        BIT     P1.4
                      13     
                      14     ;//* DS1302     Command code
  0080                15     SecondWCom      EQU     0x80
  0081                16     SecondRDCom     EQU     0x81
  0082                17     MinuteWCom      EQU     0x82
  0083                18     MinuteRDCom     EQU     0x83
  0084                19     HourWCom        EQU     0x84
  0085                20     HourRDCom       EQU     0x85
  0086                21     DateWCom        EQU     0x86    ;//* How much day of a month
  0087                22     DateRDCom       EQU     0x87
  0088                23     MonthWCom       EQU     0x88
  0089                24     MonthRDCom      EQU     0x89
  008A                25     DayWCom         EQU     0x8A    ;//* How much day of a week
  008B                26     DayRDCom        EQU     0x8B
  008C                27     YearWCom        EQU     0x8C
  008D                28     YearRDCom       EQU     0x8D
                      29     ;//*
  008E                30     ControlWCom     EQU     0x8E    ;//* enable only 7 bit, 7bit=0 may operate all register
                      31                                                     ;//* of DS1302
  008F                32     ControRDCom EQU 0x8F    ;//* only 7bit availability, 0-6bit = 0
  0090                33     TrChaWCom       EQU     0x90    ;//* This register controls the trickle charge
                      34                                                     ;//* characteristics of the DS1302.
  0091                35     TrChaRDCom      EQU     0x91    ;//* The trickle charge select (TCS) bits (bits 4-7)
                      36                                                     ;//* control the selection of the trickle c
                             harger. In
                      37                                                     ;//* order to prevent accidental enabling, 
                             only a
                      38                                                     ;//* pattern of 1010 will enable the trickl
                             e charger.
  00BE                39     CBurstWCom      EQU     0xBE    ;//* The clock/calendar command byte specifies burst 
                      40                                                     ;//* mode operation. In this mode the first
                              eight
  00BF                41     CBurstRDCom     EQU     0xBF    ;//* clock/calendar registers can be consecutively read 
                      42                                                     ;//* or written starting with bit 0 of addr
                             ess 0.
                      43     ;//* DS1302 inside buffer command code(0-31)
  00C0                44     DSBufWCom0      EQU     0xC0
  00C1                45     DSBufRDCom0     EQU     0xC1
                      46     ;//*  .
                      47     ;//*  .
                      48     ;//*  .
  00FC                49     DSBufWCom30     EQU     0xFC
  00FD                50     DSBuRDCom30 EQU 0xFD
  00FE                51     DSBufBurWC      EQU     0xFE    ;//* The RAM command byte specifies burst mode operation.
                      52                                                     ;//* In this mode, the 31 RAM registers can
                              be 
A51 MACRO ASSEMBLER  DS1302                                                               11/04/2008 14:17:15 PAGE     2

  00FF                53     DSBufBurRDC     EQU     0xFF    ;//* consecutively read or written starting with bit 0
                      54                                                     ;//* of address 0.
                      55     
                      56     ;//* date and time buffer
  0030                57     vYearBuf        EQU     0x30
  0031                58     vMonthBuf       EQU     0x31
  0032                59     vDateBuf        EQU     0x32
  0033                60     vDayBuf         EQU     0x33
  0034                61     vHourBuf        EQU     0x34
  0035                62     vMinuteBuf      EQU     0x35
  0036                63     vSecondBuf      EQU     0x36
                      64     
                      65     ;//*
                      66     ;//* **************************************************************
                      67     ;//*
0000                  68             ORG             0x0000
0000 0130             69             AJMP    Start
0030                  70             ORG             0x0030
0030                  71     Start:
0030 758160           72             MOV             SP,             #0x60
0033 787F             73         MOV     R0,     #0x7F
0035                  74     ClearRAM:
0035 7600             75         MOV     @R0,    #0
0037 D8FC             76         DJNZ    R0,     ClearRAM
                      77     
0039 759850           78         MOV   SCON, #0x50;
003C 758921           79         MOV   TMOD, #0x21; //Timer0 - 16bit timer mode
                      80     
003F 758BFD           81         MOV   TL1,  #253;
0042 758DFD           82         MOV   TH1,  #253;
                      83     
0045 D28E             84         SETB  TR1
0047 D299             85         SETB  TI
                      86     
0049 00               87             NOP
004A 00               88             NOP
                      89     
004B                  90     aaaa:
004B 00               91         NOP
004C 00               92         NOP
004D 2097FB           93         JB    P1.7,   aaaa
0050 C290             94         CLR   P1.0
0052 C291             95         CLR   P1.1
0054 1201B0           96         LCALL Delay1s
0057 D291             97         SETB  P1.1
0059 D290             98         SETB  P1.0
005B 1201B0           99         LCALL Delay1s
005E 014B            100         AJMP  aaaa
                     101     
                     102     
0060 120168          103             LCALL   INITDS1302
0063 00              104             NOP
0064 00              105             NOP
0065                 106     Loop:
0065 1200B0          107             LCALL   ReadTime
0068 00              108             NOP
0069 C299            109         CLR     TI
006B 853099          110         MOV     SBUF,  vYearBuf
006E 3099FD          111         JNB     TI,    $
                     112     
0071 C299            113         CLR     TI
0073 853199          114         MOV     SBUF,  vMonthBuf
0076 3099FD          115         JNB     TI,    $
                     116     
0079 C299            117         CLR     TI
007B 853299          118         MOV     SBUF,  vDateBuf
A51 MACRO ASSEMBLER  DS1302                                                               11/04/2008 14:17:15 PAGE     3

007E 3099FD          119         JNB     TI,    $
                     120     
0081 C299            121         CLR     TI
0083 853399          122         MOV     SBUF,  vDayBuf
0086 3099FD          123         JNB     TI,    $
                     124     
0089 C299            125         CLR     TI
008B 853499          126         MOV     SBUF,  vHourBuf
008E 3099FD          127         JNB     TI,    $
                     128     
0091 C299            129         CLR     TI
0093 853599          130         MOV     SBUF,  vMinuteBuf
0096 3099FD          131         JNB     TI,    $
                     132     
0099 C299            133         CLR     TI
009B 853699          134         MOV     SBUF,  vSecondBuf
009E 3099FD          135         JNB     TI,    $
00A1 7E00            136         MOV     R6,    #0
00A3                 137     Del:
00A3 7F00            138         MOV     R7,    #0
00A5 DFFE            139         DJNZ    R7,    $
00A7 DEFA            140         DJNZ    R6,    Del
00A9 0165            141         AJMP    Loop
00AB 00              142             NOP
                     143     ;       LCALL   WriteTime
00AC 00              144             NOP
00AD 00              145             NOP
00AE 01AE            146             AJMP    $
                     147     ;//* **************************************************************
                     148     ;//* Get year month date hour minute second
                     149     ;//*
00B0                 150     ReadTime:
00B0 748D            151             MOV     A,      #YearRDCom
00B2 12011B          152             LCALL   RDInfoFromDS1302
00B5 F530            153             MOV     vYearBuf,       A
00B7 7489            154             MOV     A,      #MonthRDCom
00B9 12011B          155             LCALL   RDInfoFromDS1302
00BC F531            156             MOV     vMonthBuf,      A
00BE 7487            157             MOV     A,      #DateRDCom
00C0 12011B          158             LCALL   RDInfoFromDS1302
00C3 F532            159             MOV     vDateBuf,       A
00C5 7485            160             MOV     A,      #HourRDCom
00C7 12011B          161             LCALL   RDInfoFromDS1302
00CA F534            162             MOV     vHourBuf,       A
00CC 7483            163             MOV     A,      #MinuteRDCom
00CE 12011B          164             LCALL   RDInfoFromDS1302
00D1 F535            165             MOV     vMinuteBuf,     A
00D3 7481            166             MOV     A,      #SecondRDCom
00D5 12011B          167             LCALL   RDInfoFromDS1302
00D8 F536            168             MOV     vSecondBuf,     A
00DA 748B            169             MOV     A,      #DayRDCom
00DC 12011B          170             LCALL   RDInfoFromDS1302
00DF F533            171             MOV     vDayBuf,        A
00E1 22              172             RET
                     173     ;//* **************************************************************
                     174     ;//* set year month date hour minute second
                     175     ;//*
00E2                 176     WriteTime:
00E2 748C            177             MOV     A,      #YearWCom
00E4 8530F0          178             MOV     B,      vYearBuf
00E7 120140          179             LCALL   WInfoToDS1302
00EA 7486            180             MOV     A,      #DateWCom
00EC 8532F0          181             MOV     B,      vDateBuf
00EF 120140          182             LCALL   WInfoToDS1302
00F2 7488            183             MOV     A,      #MonthWCom
00F4 8531F0          184             MOV     B,      vMonthBuf
A51 MACRO ASSEMBLER  DS1302                                                               11/04/2008 14:17:15 PAGE     4

00F7 120140          185             LCALL   WInfoToDS1302
00FA 7484            186             MOV     A,      #HourWCom
00FC 8534F0          187             MOV     B,      vHourBuf
00FF 120140          188             LCALL   WInfoToDS1302
0102 7480            189             MOV     A,      #SecondWCom
0104 8536F0          190             MOV     B,      vSecondBuf
0107 120140          191             LCALL   WInfoToDS1302
010A 7482            192             MOV     A,      #MinuteWCom
010C 8535F0          193             MOV     B,      vMinuteBuf
010F 120140          194             LCALL   WInfoToDS1302
0112 748A            195             MOV     A,      #DayWCom
0114 8533F0          196             MOV     B,      vDayBuf
0117 120140          197             LCALL   WInfoToDS1302
011A 22              198             RET
                     199     ;//* **************************************************************
                     200     ;//* Function:  get byte from ds1302 register
                     201     ;//* Input:             A(command code)
                     202     ;//* Output:    A(data byte)
                     203     ;//* Register:  A,R7
011B                 204     RDInfoFromDS1302:

⌨️ 快捷键说明

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