?? 萬年歷154.lst
字號:
C51 COMPILER V6.12 _騙阓_154 12/26/2009 22:22:08 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE _騙阓_154
OBJECT MODULE PLACED IN .\萬年歷154.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\萬年歷154.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include<at89x51.h>
2 #include<intrins.h>
3 unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,
4 0x6d,0x7d,0x07,0x7f,0x6f};
5 unsigned char dispbuf[15]={2,0,0,8,1,2,3,0,0,0,0,0,0,0,1}; //定義顯示緩存數組
6 sbit ds1302_data=P3^7;
7 sbit cs=P3^5;
8 sbit clk=P3^6;
9
10 unsigned char mscnt;
11 unsigned char dispbitcnt;
12
13 //短延時程序
14 void short_delay()
15 {
16 1 unsigned char i;
17 1 for(i=0;i<5;i++);
18 1 }
19 //長延時程序
20 void long_delay()
21 {
22 1 unsigned char i;
23 1 for(i=0;i<125;i++);
24 1 }
25 //向ds1302寫入一字節子程序
26 void ds1302_write(unsigned char ds1302_temp)
27 {
28 1 unsigned char i,temp;
29 1 long_delay();
30 1 temp=ds1302_temp;
31 1 for(i=0;i<8;i++)
32 1 {
33 2 ds1302_data=temp&0x01;
34 2 short_delay();
35 2 clk=1;
36 2 short_delay();
37 2 clk=0;
38 2 temp=temp>>1;
39 2 }
40 1 }
41 //從ds1302讀取一字節子程序
42 unsigned char ds1302_read(void)
43 {
44 1 unsigned char i,temp;
45 1 long_delay();
46 1 temp=0;
47 1 for(i=0;i<8;i++)
48 1 {
49 2 temp=temp>>1;
50 2 if(ds1302_data)
51 2 {
52 3 temp=temp|0x80;
53 3 }
54 2 clk=1;
55 2 short_delay();
C51 COMPILER V6.12 _騙阓_154 12/26/2009 22:22:08 PAGE 2
56 2 clk=0;
57 2 short_delay();
58 2 }
59 1 return(temp);
60 1 }
61 //主程序
62 void main(void)
63 {
64 1 unsigned char i;
65 1 TMOD=0x02;
66 1 TL0=0x06;
67 1 TH0=0x06;
68 1 TR0=1;
69 1 ET0=1;
70 1 EA=1;
71 1 cs=0;
72 1 while(1)
73 1 {
74 2 clk=0;
75 2 short_delay();
76 2 cs=1;
77 2 ds1302_write(0x81);
78 2 i=ds1302_read();
79 2 cs=0;
80 2 short_delay();
81 2 clk=1;
82 2
83 2 dispbuf[12]=(i>>4)&0x07; //秒
84 2 dispbuf[13]=i&0x0f;
85 2
86 2 clk=0;
87 2 short_delay();
88 2 cs=1;
89 2 ds1302_write(0x83);
90 2 i=ds1302_read();
91 2 cs=0;
92 2 short_delay();
93 2 clk=1;
94 2
95 2 dispbuf[10]=(i>>4)&0x07; //分
96 2 dispbuf[11]=i&0x0f;
97 2
98 2 clk=0;
99 2 short_delay();
100 2 cs=1;
101 2 ds1302_write(0x85);
102 2 i=ds1302_read();
103 2 cs=0;
104 2 short_delay();
105 2 clk=1;
106 2
107 2 dispbuf[8]=(i>>4)&0x03; //小時
108 2 dispbuf[9]=i&0x0f;
109 2
110 2 clk=0;
111 2 short_delay();
112 2 cs=1;
113 2 ds1302_write(0x87);
114 2 i=ds1302_read();
115 2 cs=0;
116 2 short_delay();
117 2 clk=1;
C51 COMPILER V6.12 _騙阓_154 12/26/2009 22:22:08 PAGE 3
118 2
119 2 dispbuf[6]=(i>>4)&0x03; //日
120 2 dispbuf[7]=i&0x0f;
121 2
122 2 clk=0;
123 2 short_delay();
124 2 cs=1;
125 2 ds1302_write(0x89);
126 2 i=ds1302_read();
127 2 cs=0;
128 2 short_delay();
129 2 clk=1;
130 2
131 2 dispbuf[4]=(i>>4)&0x01; //月
132 2 dispbuf[5]=i&0x0f;
133 2
134 2 clk=0;
135 2 short_delay();
136 2 cs=1;
137 2 ds1302_write(0x8d);
138 2 i=ds1302_read();
139 2 cs=0;
140 2 short_delay();
141 2 clk=1;
142 2
143 2 dispbuf[2]=(i>>4)&0x0f; //年
144 2 dispbuf[3]=i&0x0f;
145 2
146 2 clk=0;
147 2 short_delay();
148 2 cs=1;
149 2 ds1302_write(0x8b);
150 2 i=ds1302_read();
151 2 cs=0;
152 2 short_delay();
153 2 clk=1;
154 2
155 2 dispbuf[14]=((i&0x07)-1); //周
156 2
157 2 }
158 1 }
159
160 void t0(void)interrupt 1 using 0
161 {
162 1 mscnt++;
163 1 if(mscnt==8) //2ms數碼管掃描顯示
164 1 {
165 2 mscnt=0;
166 2 P2=dispbitcnt;
167 2 P1=dispcode[dispbuf[dispbitcnt]];
168 2 dispbitcnt++;
169 2 if(dispbitcnt==15)
170 2 dispbitcnt=0;
171 2 }
172 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 332 ----
CONSTANT SIZE = 10 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
C51 COMPILER V6.12 _騙阓_154 12/26/2009 22:22:08 PAGE 4
DATA SIZE = 17 ----
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 + -