51_LanQiaoBei/模板/zuolan_v1标志位/prj/Listings/ds1302.lst
2025-04-13 01:02:19 +08:00

124 lines
4.0 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

C51 COMPILER V9.60.7.0 DS1302 03/10/2025 18:03:53 PAGE 1
C51 COMPILER V9.60.7.0, COMPILATION OF MODULE DS1302
OBJECT MODULE PLACED IN .\Objects\ds1302.obj
COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE ..\driver\ds1302.c OPTIMIZE(8,SPEED) BROWSE INCDIR(..\driver;..\user) DE
-BUG OBJECTEXTEND PRINT(.\Listings\ds1302.lst) TABS(2) OBJECT(.\Objects\ds1302.obj)
line level source
1 /* # DS1302莉」遐∫援谿オ隸エ譏<EFBDB4>
2 1. 譛ャ譁<EFBDAC>サカ螟ケ荳ュ謠蝉セ帷噪鬩ア蜉ィ莉」遐∽セ帛盾襍幃€画焔螳梧<E89EB3>遞句コ剰ョセ隶。蜿り€<E3828A>€<EFBFBD>
3 2.
4 蜿りオ幃€画焔蜿ッ莉・閾ェ陦檎シ門<EFBDBC>逶ク蜈ウ莉」遐∵<E98190>莉・隸・莉」遐∽クコ蝓コ遑€<E98191><EFBFBD>ケ謐ョ謇€騾牙黒迚<E9BB92>惻邀サ蝙九€∬ソ占
-。碁€溷コヲ蜥瑚ッ暮「<E69AAE>
5 荳ュ蟇ケ蜊慕援譛コ譌カ髓滄「醍紫逧<E7B4AB>ヲ∵アゑシ瑚ソ幄。御サ」遐∬ー<E288AC>ッ募柱菫ョ謾ケ縲<EFBDB9>
6 */
7 #include "ds1302.h"
8
9 #include "intrins.h"
10 sbit SDA = P2 ^ 3;
11 sbit RST = P1 ^ 3;
12 sbit SCK = P1 ^ 7;
13 //
14 void Write_Ds1302(unsigned char temp)
15 {
16 1 unsigned char i;
17 1 for (i = 0; i < 8; i++)
18 1 {
19 2 SCK = 0;
20 2 SDA = temp & 0x01;
21 2 temp >>= 1;
22 2 SCK = 1;
23 2 }
24 1 }
25
26 //
27 void Write_Ds1302_Byte(unsigned char address, unsigned char dat)
28 {
29 1 RST = 0;
30 1 _nop_();
31 1 SCK = 0;
32 1 _nop_();
33 1 RST = 1;
34 1 _nop_();
35 1 Write_Ds1302(address);
36 1 Write_Ds1302(dat);
37 1 RST = 0;
38 1 }
39
40 //
41 unsigned char Read_Ds1302_Byte(unsigned char address)
42 {
43 1 unsigned char i, temp = 0x00;
44 1 RST = 0;
45 1 _nop_();
46 1 SCK = 0;
47 1 _nop_();
48 1 RST = 1;
49 1 _nop_();
50 1 Write_Ds1302(address);
51 1 for (i = 0; i < 8; i++)
52 1 {
53 2 SCK = 0;
C51 COMPILER V9.60.7.0 DS1302 03/10/2025 18:03:53 PAGE 2
54 2 temp >>= 1;
55 2 if (SDA)
56 2 temp |= 0x80;
57 2 SCK = 1;
58 2 }
59 1 RST = 0;
60 1 _nop_();
61 1 SCK = 0;
62 1 _nop_();
63 1 SCK = 1;
64 1 _nop_();
65 1 SDA = 0;
66 1 _nop_();
67 1 SDA = 1;
68 1 _nop_();
69 1 return (temp);
70 1 }
71 // 蜊∬ソ帛宛 11 -> 0x11
72 void Set_Rtc(unsigned char *ucRtc)
73 {
74 1 unsigned char i;
75 1 unsigned char temp;
76 1 Write_Ds1302_Byte(0x8e, 0x00);
77 1 Write_Ds1302_Byte(0x80, 0x80);
78 1 for (i = 0; i < 3; i++)
79 1 {
80 2
81 2 temp = (ucRtc[i] / 10) * 16 + ucRtc[i] % 10;
82 2 Write_Ds1302_Byte(0x84 - 2 * i, temp);
83 2 }
84 1 Write_Ds1302_Byte(0x8e, 0x80);
85 1 }
86 // 蜊∬ソ帛宛 0x11 -> 11
87 void Read_Rtc(unsigned char *ucRtc)
88 {
89 1 unsigned char i;
90 1 unsigned char temp;
91 1 for (i = 0; i < 3; i++)
92 1 {
93 2 temp = Read_Ds1302_Byte(0x85 - 2 * i);
94 2 ucRtc[i] = temp / 16 * 10 + temp % 16;
95 2 }
96 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 222 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 6
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)