📄 shizhong.lst
字号:
C51 COMPILER V7.50 SHIZHONG 03/01/2009 08:47:26 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE SHIZHONG
OBJECT MODULE PLACED IN shizhong.OBJ
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE shizhong.c BROWSE DEBUG OBJECTEXTEND
line level source
1 ////////////////////////////////////////////////////////////////////////////////
2 #include <reg52.h>
3 #include <ds18b20.h>
4 //共阴代码
5 unsigned char cathcode[21] ={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67,
6 0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xe7,0x40};
7 unsigned char nf[]={0x71,0x37,0x00};
8 unsigned char second,minute,hour;
9 unsigned int c_second,c_minute,t;
10 unsigned char k,n,temp;
11 unsigned char flag_A=0,toolong=0,flash=0,th=0,tm=0,on_or_off;
12
13 sbit buttona=P0^0; //定义各个为变量
14 sbit buttonb=P0^1;
15 sbit buttonc=P0^2;
16 sbit buttond=P0^3;
17 /*----------------------------------------------*/
18 void delay(unsigned char k) //延时函数
19 {
20 1 unsigned char j;
21 1 while(k--)
22 1 for (j=0;j<125;j++)
23 1 ;
24 1 }
25
26 /*-------------------shansuoxianshi-------------*/
27 void flashdisplaytimer()
28 {
29 1 if(flag_A==4)
30 1 {
31 2 if(++flash<8)
32 2 {
33 3 P1=0;
34 3 P1=cathcode[th/10];
35 3 P2=0;delay(1);P1=0;
36 3 P1=cathcode[th%10+10];
37 3 P2=1;delay(1);
38 3 }
39 2 }
40 1 else
41 1 {
42 2 P1=0;
43 2 P1=cathcode[th/10];
44 2 P2=0;delay(1);P1=0;
45 2 P1=cathcode[th%10+10];
46 2 P2=1;delay(1);
47 2 }
48 1 if(flag_A==5)
49 1 {
50 2 if(++flash<5)
51 2 {
52 3 P1=cathcode[tm/10];
53 3 P2=2;delay(1);P1=0;
54 3 P1=cathcode[tm%10+10];
55 3 P2=3;delay(1);P1=0;
C51 COMPILER V7.50 SHIZHONG 03/01/2009 08:47:26 PAGE 2
56 3 }
57 2 }
58 1 else
59 1 {
60 2 P1=cathcode[tm/10];
61 2 P2=2;delay(1);P1=0;
62 2 P1=cathcode[tm%10+10];
63 2 P2=3;delay(1);P1=0;
64 2 }
65 1
66 1
67 1
68 1
69 1 P1=0x40;
70 1 P2=4;delay(1);P1=0;
71 1
72 1
73 1 if(flag_A==6)
74 1 {
75 2 if(++flash<5)
76 2 {
77 3 P1=0x3f;
78 3 P2=5;delay(1);P1=0;
79 3 P1=nf[on_or_off];
80 3 P2=6;delay(1);P1=0;
81 3 if(on_or_off==1);
82 3 else
83 3 {P1=nf[on_or_off];
84 4 P2=7;delay(1);P1=0;}
85 3 }
86 2 }
87 1 else
88 1 {
89 2 P1=0x3f;
90 2 P2=5;delay(1);P1=0;
91 2 P1=nf[on_or_off];
92 2 P2=6;delay(1);P1=0;
93 2 if(on_or_off==1);
94 2 else
95 2 {P1=nf[on_or_off];
96 3 P2=7;delay(1);P1=0;}
97 2 }
98 1 if(flash>20)flash=0;
99 1
100 1 }
101
102 /*-------------------shansuoxianshi-------------*/
103 void flashdisplay()
104 {
105 1 if(flag_A==1)
106 1 {
107 2 if(++flash<8)
108 2 {
109 3 P1=0;
110 3 P1=cathcode[hour/10];
111 3 P2=0;delay(1);P1=0;
112 3 P1=cathcode[hour%10+10];
113 3 P2=1;delay(1);
114 3 }
115 2 }
116 1 else
117 1 {
C51 COMPILER V7.50 SHIZHONG 03/01/2009 08:47:26 PAGE 3
118 2 P1=0;
119 2 P1=cathcode[hour/10];
120 2 P2=0;delay(1);P1=0;
121 2 P1=cathcode[hour%10+10];
122 2 P2=1;delay(1);
123 2 }
124 1 if(flag_A==2)
125 1 {
126 2 if(++flash<5)
127 2 {
128 3 P1=cathcode[minute/10];
129 3 P2=2;delay(1);P1=0;
130 3 P1=cathcode[minute%10+10];
131 3 P2=3;delay(1);P1=0;
132 3 }
133 2 }
134 1 else
135 1 {
136 2 P1=cathcode[minute/10];
137 2 P2=2;delay(1);P1=0;
138 2 P1=cathcode[minute%10+10];
139 2 P2=3;delay(1);P1=0;
140 2 }
141 1 if(flag_A==3)
142 1 {
143 2 if(++flash<8)
144 2 {
145 3 P1=cathcode[second/10];
146 3 P2=4;delay(1);P1=0;
147 3 P1=cathcode[second%10+10];
148 3 P2=5;delay(1);P1=0;
149 3 }
150 2 }
151 1 else
152 1 {
153 2 P1=cathcode[second/10];
154 2 P2=4;delay(1);P1=0;
155 2 P1=cathcode[second%10+10];
156 2 P2=5;delay(1);P1=0;
157 2 }
158 1 if(tempflag==0)
159 1 {P1=cathcode[temp/10];
160 2 P2=6;delay(1);P1=0;}
161 1 else
162 1 {P1=cathcode[20];
163 2 P2=6;delay(1);P1=0;}
164 1 P1=cathcode[temp%10];
165 1 P2=7;
166 1 delay(1);
167 1 if(flash>20)flash=0;
168 1
169 1 }
170
171
172 /*------------------------------------------------------------------------------*/
173 void display() //显示程序八位数码管。六位温度
174 {unsigned char i=5; //两位显示温度。
175 1 while(i--)
176 1 {P1=0;
177 2 P1=cathcode[hour/10];
178 2 P2=0;delay(1);P1=0;
179 2 P1=cathcode[hour%10+10];
C51 COMPILER V7.50 SHIZHONG 03/01/2009 08:47:26 PAGE 4
180 2 P2=1;delay(1);P1=0;
181 2 P1=cathcode[minute/10];
182 2 P2=2;delay(1);P1=0;
183 2 P1=cathcode[minute%10+10];
184 2 P2=3;delay(1);P1=0;
185 2 P1=cathcode[second/10];
186 2 P2=4;delay(1);P1=0;
187 2 P1=cathcode[second%10+10];
188 2 P2=5;delay(1);P1=0;
189 2 if(tempflag==0)
190 2 {P1=cathcode[temp/10];
191 3 P2=6;delay(1);P1=0;}
192 2 else
193 2 {P1=cathcode[20];
194 3 P2=6;delay(1);P1=0;}
195 2 P1=cathcode[temp%10];
196 2 P2=7;
197 2 delay(1);
198 2
199 2 }
200 1 }
201 /*-------------------------------------------------------------------------*/
202 /*--------------------------键盘扫描函数-------------*/
203 void scan_a() //scan button A
204 {
205 1 if(buttona==0)
206 1 {delay(10);
207 2 if(buttona==0)
208 2 if(++flag_A>6)flag_A=0;
209 2 toolong=0; //if button A effective the flag clear
210 2 }
211 1 while(!buttona); //wait a
212 1 }
213
214 void scan_c() //scan key c
215 {
216 1 if(buttonc==0)
217 1 {delay(10);
218 2 if(buttonc==0)
219 2 {toolong=0;
220 3 if(flag_A==1)
221 3 {if(++hour>23)hour=0;}
222 3 else
223 3 {if(flag_A==2)
224 4 {if(++minute>59)minute=0;}
225 4 else
226 4 {if(flag_A==3)second=0;
227 5 else
228 5 {if(flag_A==4)
229 6 {if(++th>23)th=0;}
230 6 else
231 6 {if(flag_A==5)
232 7 {if(++tm>59)tm=0;}
233 7 else
234 7 on_or_off=1;
235 7 }
236 6 }
237 5 }
238 4
239 4 }
240 3 }
241 2 }
C51 COMPILER V7.50 SHIZHONG 03/01/2009 08:47:26 PAGE 5
242 1 while(!buttonc);
243 1 }
244
245 void scan_d()
246 {
247 1 if(buttond==0)
248 1 {delay(10);
249 2 if(buttond==0)
250 2 {toolong=0;
251 3 if(flag_A==1)
252 3 {if(--hour>100)hour=23;}
253 3 else
254 3 {if(flag_A==2)
255 4 {if(--minute>100)minute=59;}
256 4 else
257 4 if(flag_A==3)second=30;
258 4 else
259 4 {if(flag_A==4)
260 5 {if(--th>100)th=23;}
261 5 else
262 5 {if(flag_A==5)
263 6 {if(--th>100)tm=59;}
264 6 else
265 6 on_or_off=0;
266 6 }
267 5 }
268 4
269 4
270 4
271 4 }
272 3
273 3 }
274 2 }
275 1 while(!buttond);
276 1 }
277 /*-------------------------------------------*/
278
279 void main () //主函数
280 {
281 1 TMOD=0x02;
282 1 TH0=0x06;
283 1 TL0=0x06;
284 1 TR0=1;
285 1 ET0=1;
286 1 EA=1; //启动定时器,方式2.开定时器中断
287 1 n=0;
288 1 c_second=0;
289 1 c_minute=0;
290 1 hour=23;
291 1 minute=59;
292 1 second=30;
293 1 //开机显示23:59:30
294 1
295 1 while(1)
296 1 {
297 2 scan_a();
298 2 if(flag_A)
299 2 {scan_c();
300 3 scan_d();}
301 2 if(toolong>30)flag_A=0;
302 2
303 2
C51 COMPILER V7.50 SHIZHONG 03/01/2009 08:47:26 PAGE 6
304 2 if(flag_A==0)
305 2 display();
306 2 else
307 2 if(flag_A<=3)
308 2 flashdisplay();
309 2 else
310 2 flashdisplaytimer();
311 2 if(toolong>30)flag_A=0;
312 2 //温度每秒采样一次
313 2
314 2 t=ReadTemperature();
315 2 temp=(int)(t) ;
316 2
317 2 //if(temp>99)temp%=100;
318 2 //if(temp<1)temp=0;
319 2 }
320 1
321 1 }
322
323 void t0(void) interrupt 1 using 1 //中断函数
324 {
325 1 c_second++;
326 1 c_minute++;
327 1 if(c_second==8000)
328 1 {
329 2 c_second=0;
330 2 second++;
331 2 toolong=0; //调整时间标志位
332 2 if(second==60)
333 2 {minute++;
334 3 if(minute==60)
335 3 {hour++;
336 4 if(hour>23)
337 4 {
338 5 hour=0;
339 5 }
340 4 minute=0;
341 4 }
342 3 second=0;
343 3 }
344 2 }
345 1 }
346
347
348
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1311 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 43 1
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 + -