📄 retime.lst
字号:
C51 COMPILER V8.02 RETIME 06/24/2007 13:22:44 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE RETIME
OBJECT MODULE PLACED IN retime.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE retime.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /***************************************
2 名称:2008奥运会倒计时
3 ***************************************/
4 #include<reg51.h>
5 #include<absacc.h>
6 #include<intrins.h>
7 #include "delay.h"
8 #define clock_segment XBYTE[0xBFFF] //时钟段码地址
9 #define clock_sel XBYTE[0x7FFF] //时钟位码地址
10 #define year_segment XBYTE[0xEFFF] //日历段码地址
11 #define year_sel XBYTE[0xDFFF] //日历位码地址
12 #define retime_segment XBYTE[0xFBFF]//倒计时段码地址
13 #define retime_sel XBYTE[0xF7FF] //倒计时位码地址
14
15 unsigned char time_num=0;//定时一秒次数
16 unsigned char shi_num=24;//小时位计数
17 unsigned char miao_ge=0; //秒个位
18 unsigned char miao_shi=0;//秒十位
19 unsigned char fen_ge=0;//分个位
20 unsigned char fen_shi=4;//分十位
21 unsigned char shi_ge=8;//时个位
22 unsigned char shi_shi=0;//时十位
23 unsigned char year_thousand=2;
24 unsigned char year_hundred=0;
25 unsigned char year_decade=0;
26 unsigned char year_unit=7;
27 unsigned char month_decade=0;
28 unsigned char month_unit=6;
29 unsigned char day_decade=2;
30 unsigned char day_unit=6;
31 unsigned char retime_unit=0;
32 unsigned char retime_decade=1;
33 unsigned char retime_hundred=4;
34 unsigned char retime_thousand=0;
35
36 unsigned char year_thoustore; //保存年千位数据
37 unsigned char year_hundstore; //保存年百位数据
38 unsigned char year_decastore; //保存年十位数据
39 unsigned char year_unitstore; //保存年个位数据
40 unsigned char month_unitstore;//保存月个位数据
41 unsigned char month_decastore;//保存月十位数据
42 unsigned char day_unitstore; //保存日个位数据
43 unsigned char day_decastore; //保存日十位数据
44 unsigned char year_unitstore2;//保存年各位数据
45 unsigned char year_decastore2;//年位组合子程序用来保护数据用
46 unsigned char year_hundstore2;
47 unsigned char year_thoustore2;
48 unsigned char retime_ustore; //保存倒计时各位数据
49 unsigned char retime_dstore;
50 unsigned char retime_hstore;
51 unsigned char retime_tstore;
52 unsigned char day_numj=31; //奇数月31天
53 unsigned char day_numo=30; //偶数月30天
54 unsigned char day_numooo=30;
55 unsigned char day_numoo;
C51 COMPILER V8.02 RETIME 06/24/2007 13:22:44 PAGE 2
56 unsigned char month_num=12;
57 unsigned int year_jointed; //年各位组合在一起,以便进行闰年判断
58 unsigned int year_help1;
59 unsigned int year_help2;
60 unsigned char xiaoshi_ge;//闪烁时存小时个位
61 unsigned char xiaoshi_shi;//闪烁时存小时十位
62 unsigned char fenzhong_ge;//闪烁时存分钟个位
63 unsigned char fenzhong_shi;//闪烁时存分钟十位
64 unsigned char cort=0;//判断第几次按下确认键
65 sbit key_sure=P1^0;//调时或确认键
66 sbit key_dec=P1^2;//调时减键
67 bit first_sure=0; //第一次按下确认键
68 bit second_sure=0;//第二次按下确认键
69 bit third_sure=0; //第三次按下确认键
70 bit fourth_sure=0;//第四次按下确认键
71 bit fifth_sure=0; //第五次按下确认键
72 bit sixth_sure=0; //第六次按下确认键
73 bit seventh_sure=0;//第七次按下确认键
74 unsigned code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00};//段码表
75 /************函数声明*************/
76 void shannum_jian(void);
77 void inc_key(void);
78 void dec_key(void);
79 void dis_dingshi(void);
80 void hour_shanshuo(void);
81 void min_shanshuo(void);
82 void kbscan(void);
83 void display(void);
84 void year_joint(void);
85 unsigned char judgement_leap(void);
86 void retime_flash(void);
87 /********************************
88 显示子程序
89 *********************************/
90 void display(void)
91 {
92 1 clock_sel=0xdf;
93 1 clock_segment=table[miao_ge]; //送秒个位段位码
94 1 delay(3);
95 1 clock_sel=0xef;
96 1 clock_segment=table[miao_shi]; //送秒十位段位码
97 1 delay(3);
98 1 clock_sel=0xf7;
99 1 clock_segment=table[fen_ge]|0x80; //送分个位段位码
100 1 delay(3);
101 1 clock_sel=0xfb;
102 1 clock_segment=table[fen_shi]; //送分十位段位码
103 1 delay(3);
104 1 clock_sel=0xfd;
105 1 clock_segment=table[shi_ge]|0x80; //送时个位段位码
106 1 delay(3);
107 1 clock_sel=0xfe;
108 1 clock_segment=table[shi_shi]; //送时十位段位码
109 1 delay(3);
110 1 year_sel=0x7f;
111 1 year_segment=table[day_unit]; //送日个位段位码
112 1 delay(3);
113 1 year_sel=0xbf;
114 1 year_segment=table[day_decade]; //送日十位段位码
115 1 delay(3);
116 1 year_sel=0xdf;
117 1 year_segment=table[month_unit]|0x80; //送月个位段位码
C51 COMPILER V8.02 RETIME 06/24/2007 13:22:44 PAGE 3
118 1 delay(3);
119 1 year_sel=0xef;
120 1 year_segment=table[month_decade]; //送月十位段位码
121 1 delay(3);
122 1 year_sel=0xf7;
123 1 year_segment=table[year_unit]|0x80; //送年个位段位码
124 1 delay(3);
125 1 year_sel=0xfb;
126 1 year_segment=table[year_decade]; //送年十位段位码
127 1 delay(3);
128 1 year_sel=0xfd;
129 1 year_segment=table[year_hundred]; //送年百位段位码
130 1 delay(3);
131 1 year_sel=0xfe;
132 1 year_segment=table[year_thousand]; //送年千位段位码
133 1 delay(3);
134 1 retime_sel=0xf7;
135 1 retime_segment=table[retime_unit]; //送倒计时个位段位码
136 1 delay(3);
137 1 retime_sel=0xfb;
138 1 retime_segment=table[retime_decade]; //送倒计时十位段位码
139 1 delay(3);
140 1 retime_sel=0xfd;
141 1 retime_segment=table[retime_hundred];//送倒计时百位段位码
142 1 delay(3);
143 1 retime_sel=0xfe;
144 1 retime_segment=table[retime_thousand];//送倒计时千位段位码
145 1 delay(3);
146 1
147 1 }
148 /**********************************
149 判断闰年子程序
150 ***********************************/
151 unsigned char judgement_leap(void)
152 {
153 1 year_joint(); //调用年各位组合子程序
154 1 if((year_jointed%4==0&&year_jointed%100!=0)||(year_jointed%100==0&&year_jointed%400==0))return(29); //
-是闰年二月29天
155 1 else return(28); //是平年二月28天
156 1 }
157 /**********************************
158 按键扫描子程序
159 ***********************************/
160 void kbscan(void)
161 {
162 1 unsigned char sccode;
163 1 P1=0xff;
164 1 if((P1&0xff)!=0xff)
165 1 {
166 2 //delay(5);
167 2 display();
168 2 display();
169 2 display();
170 2
171 2 if((P1&0xff)!=0xff)
172 2 {
173 3 sccode=P1;
174 3 //while((P1&0xff)!=0xff) //按键后消陡
175 3 //{
176 3 // ;
177 3 // }
178 3 switch(sccode)
C51 COMPILER V8.02 RETIME 06/24/2007 13:22:44 PAGE 4
179 3 {
180 4 case 0xfe:shannum_jian();break;
181 4 case 0xfd:inc_key(); break;
182 4 case 0xfb:dec_key(); break;
183 4 default: break;
184 4 }
185 3 }
186 2 }
187 1 }
188 /********************************
189 确认键按键次数子程序
190 ********************************/
191 void shannum_jian(void)
192 {
193 1 cort++;
194 1 if(cort==1) //第一次按下确认键
195 1 {
196 2 first_sure=1;
197 2 second_sure=0;
198 2 third_sure=0;
199 2 fourth_sure=0;
200 2 fifth_sure=0;
201 2 sixth_sure=0;
202 2 seventh_sure=0;
203 2
204 2 }
205 1 else if(cort==2) //第二次按下确认键
206 1 {
207 2 first_sure=0;
208 2 second_sure=1;
209 2 third_sure=0;
210 2 fourth_sure=0;
211 2 fifth_sure=0;
212 2 sixth_sure=0;
213 2 seventh_sure=0;
214 2
215 2 }
216 1 else if(cort==3) //第三次按下确认键
217 1 {
218 2 first_sure=0;
219 2 second_sure=0;
220 2 third_sure=1;
221 2 fourth_sure=0;
222 2 fifth_sure=0;
223 2 sixth_sure=0;
224 2 seventh_sure=0;
225 2
226 2 }
227 1 else if(cort==4) //第四次按下确认键
228 1 {
229 2 first_sure=0;
230 2 second_sure=0;
231 2 third_sure=0;
232 2 fourth_sure=1;
233 2 fifth_sure=0;
234 2 sixth_sure=0;
235 2 seventh_sure=0;
236 2
237 2 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -