📄 time.lst
字号:
C51 COMPILER V8.02 TIME 08/22/2007 19:41:21 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE TIME
OBJECT MODULE PLACED IN time.OBJ
COMPILER INVOKED BY: C:\Keil\C51\Bin\c51.exe time.c DB SB OE ROM(LARGE) SMALL OT(6,SPEED) WL(2) RB(0)
line level source
*** WARNING C500 IN LINE 1 OF TIME.C: LICENSE ERROR (R225: REGISTRATION FILE 'TOOLS.INI' NOT FOUND)
1 #include<reg52.h>
2 #include<absacc.h>
3 #include <stdio.h>
4 #include <intrins.h>
5
6 xdata unsigned char CW _at_ 0xf9fc; //?????
7 xdata unsigned char CR _at_ 0xf9fe;
8 xdata unsigned char DW _at_ 0xf9fd;
9 xdata unsigned char DR _at_ 0xf9ff;
10 unsigned char key;
11 bit flag;
12 int k;
13
14 int g; //取月份
15 int f=29; //f进位标志
16
17 int clockon; //闹钟开关
18
19
20 void delay(unsigned int i)
21 { while(i--);
22 1 }
23 unsigned char lc_read(void)
24 { unsigned char a;
25 1 delay(100);
26 1 a=CR;
27 1 return(a);
28 1 }
29 void readbf(void)
30 { while(flag)
31 1 { flag=(bit)(lc_read())&0x80; //????
32 2 }
33 1 }
34 void lc_write(unsigned char a)
35 { delay(20);
36 1 CW=a;
37 1 delay(20);
38 1 }
39 void ld_write(unsigned char a)
40 { delay(20);
41 1 DW=a;
42 1 delay(20);
43 1 }
44 void inttilcs(void)
45 {
46 1 readbf();
47 1 lc_write(0x38);
48 1 delay(500);
49 1 readbf();
50 1 lc_write(0x38);
51 1 delay(500);
52 1 readbf();
53 1 lc_write(0x38);
54 1 delay(500);
C51 COMPILER V8.02 TIME 08/22/2007 19:41:21 PAGE 2
55 1 lc_write(0x01);
56 1 readbf();
57 1 lc_write(0x0f);
58 1 readbf();
59 1 delay(500);
60 1 lc_write(0x0f);
61 1 readbf();
62 1 delay(500);
63 1 lc_write(0x06);
64 1 delay(500);
65 1 }
66
67 unsigned char code display_code[10]=
68 {
69 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39 //0,1,2,3,4,5,6,7,8,9
-
70 };
71 unsigned char data display_data_buff[15]={2,0,0,6,0,1,0,1,1,2,0,0,0,0,1};//数据显示缓冲区 ??????
72 unsigned char data display_code_buff[15]={2,0,0,6,0,1,0,1,1,2,0,0,0,0,1};//段码显示缓冲区
73
74 struct time_str
75 {signed char year;
76 unsigned char month;
77 unsigned char day;
78 signed char hour;
79 signed char minute;
80 signed char second;
81 unsigned char second20;
82 unsigned char week;
83 }time;
84
85
86 /* struct clock_str
87 {unsigned char hour;
88 unsigned char minute;
89 }clock;*/
90 //**************************************************************************
91 void dp_data_to_dp_code_buff(void)
92 {
93 1 unsigned char i;
94 1 for (i=0;i<15;i++)
95 1 {
96 2 display_code_buff[i]=display_code[display_data_buff[i]];
97 2 }
98 1 }
99 //**************************************************************************
100
101 void js_week()
102 {
103 1 //计算星期几
104 1 int i;
105 1
106 1 int n;
107 1
108 1 int year,month,day;
109 1
110 1 int a1[12]={31,28,31,30,31,30,31,31,30,31,30,31};
111 1
112 1 year=time.year+2000;
113 1 month=time.month;
114 1 day=time.day;
115 1
C51 COMPILER V8.02 TIME 08/22/2007 19:41:21 PAGE 3
116 1 if (year%4==0 && year%100!=0)
117 1
118 1 { a1[1]=29;f=30;}
119 1
120 1 if (year%400==0)
121 1
122 1 {a1[1]=29;f=30;}
123 1
124 1 for(i=0;i<month-1;i++)
125 1
126 1 day+=a1[i];
127 1
128 1
129 1 n=year-1900+(year-1901)/4+day;
130 1
131 1 n=n%7; //星期几
132 1
133 1 time.week=n;
134 1
135 1
136 1 }
137
138 int jinwei(int d)
139 {
140 1 g=time.month;
141 1 switch(g)
142 1
143 1 {
144 2 case 1:
145 2 case 3:
146 2 case 5:
147 2 case 7:
148 2 case 8:
149 2 case 10:
150 2 case 12: f=32;break;
151 2
152 2 case 4:
153 2 case 6:
154 2 case 9:
155 2 case 11:f=31;break;
156 2
157 2
158 2
159 2
160 2 }
161 1 return f;
162 1
163 1
164 1
165 1 }
*** WARNING C280 IN LINE 138 OF TIME.C: 'd': unreferenced local variable
166 void time_to_display_data_buff(void)
167 { display_data_buff[0]=2;
168 1 display_data_buff[1]=0;
169 1 display_data_buff[2]=time.year/10;
170 1 display_data_buff[3]=time.year%10;
171 1 display_data_buff[4]=time.month/10;
172 1 display_data_buff[5]=time.month%10;
173 1 display_data_buff[6]=time.day/10;
174 1 display_data_buff[7]=time.day%10;
175 1 display_data_buff[8]=time.hour/10;
176 1 display_data_buff[9]=time.hour%10;
C51 COMPILER V8.02 TIME 08/22/2007 19:41:21 PAGE 4
177 1 display_data_buff[10]=time.minute/10;
178 1 display_data_buff[11]=time.minute%10;
179 1 display_data_buff[12]=time.second/10;
180 1 display_data_buff[13]=time.second%10;
181 1
182 1 js_week();//计算星期
183 1
184 1 display_data_buff[14]=time.week;
185 1
186 1 dp_data_to_dp_code_buff();
187 1
188 1 }
189
190 void display2(void)
191 {
192 1 ld_write(0x20); //空格
193 1 ld_write(display_code_buff[0]);
194 1 ld_write(display_code_buff[1]);
195 1 ld_write(display_code_buff[2]);
196 1 ld_write(display_code_buff[3]);
197 1 ld_write(0xb0);
198 1
199 1 ld_write(display_code_buff[4]);
200 1 ld_write(display_code_buff[5]);
201 1 ld_write(0xb0);
202 1 ld_write(display_code_buff[6]);
203 1 ld_write(display_code_buff[7]);
204 1 ld_write(0x3c);
205 1 ld_write(display_code_buff[14]);
206 1
207 1 ld_write(0x3e);
208 1
209 1 lc_write(0x40);
210 1 lc_write(0x14);
211 1 readbf();
212 1
213 1 ld_write(display_code_buff[8]);
214 1 ld_write(display_code_buff[9]);
215 1 ld_write(0x3a); // “:”
216 1
217 1 ld_write(display_code_buff[10]);
218 1 ld_write(display_code_buff[11]);
219 1 ld_write(0x3a);
220 1 ld_write(display_code_buff[12]);
221 1 ld_write(display_code_buff[13]);
222 1 /* if(clockon==1&time.hour==clock.hour&time.minute==clock.minute)
223 1 {
224 1 ld_write(0x20);
225 1 ld_write(0x40);
226 1
227 1 }*/
228 1
229 1 }
230
231
232
233
234 void display(void)
235 {
236 1
237 1 time.second20++;
238 1 if (time.second20==18)
C51 COMPILER V8.02 TIME 08/22/2007 19:41:21 PAGE 5
239 1 {
240 2 time.second20=0;
241 2 time.second++;
242 2 if (time.second==60)
243 2 {
244 3 time.second=0;
245 3 time.minute++;
246 3 if (time.minute==60)
247 3 {
248 4 time.minute=0;
249 4 time.hour++;
250 4 if (time.hour==24)
251 4 {
252 5 time.hour=0;
253 5 time.day++;
254 5
255 5 if(time.week==8)
256 5 time.week=1;
257 5
258 5
259 5 if(time.day==jinwei())
*** WARNING C209 IN LINE 259 OF TIME.C: '_jinwei': too few actual parameters
260 5 {
261 6 time.day=1;
262 6
263 6 time.month++;
264 6
265 6 if(time.month==13)
266 6 {
267 7 time.month=1;
268 7 time.year++;
269 7
270 7 }
271 6 }
272 5
273 5 }
274 4
275 4 }
276 3 }
277 2
278 2 delay(500);
279 2 lc_write(0x01);
280 2 time_to_display_data_buff();
281 2
282 2
283 2 delay(500);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -