📄 counter3.lst
字号:
181 2 p->count_bits[j]=i%10;
182 2 i/=10;
183 2 }
184 1 if(p-count_buff==1)
185 1 {
186 2 p->count_bits[5]=10;
187 2 p->count_bits[4]=12;
188 2 }
189 1 if(p-count_buff==2)
190 1 {
191 2 p->count_bits[5]=11;
192 2 p->count_bits[4]=12;
193 2 }
194 1 }
195 ////////////////////////////////////////////////////
196 void led_display(void)
197 {
198 1 unsigned char k,n,temp,num;
199 1 unsigned int j;
200 1 j++;if(j>30) j=0;
201 1 if(status==0)
202 1 {
203 2 for(n=7;(n>1&&p->count_bits[n-1]==0);n--)//前面的0关掉不显示***********
204 2 ;
205 2 }
206 1 else n=6;
207 1 temp=0x80;
208 1
209 1 for(k=0;k<n;k++)//从右到左扫描,低位到高位
210 1 {
211 2 num=p->count_bits[k];
212 2 if(p-count_buff==3)//*************
213 2 com_port=led_tab[num]&0x7f;
214 2 else
215 2 com_port=led_tab[num];
216 2 if(k==count_bit&&j<16&&count_bit>=0)
217 2 {
218 3 bit_port=0xff;
219 3 }
220 2 else if(j<14&& flash_all==1)
221 2 bit_port=0xff;
222 2 else
223 2 bit_port=~temp;
224 2 temp=temp>>1;
225 2 delay(150);
226 2 bit_port=0xff;//消除鬼影
227 2 }
228 1
229 1 }
230 /////////////////////////////////////////////////////////////
231 unsigned char scan_key(void)
232 {
233 1 unsigned char result=0;
234 1 P1|=0x78;//0111 1000
235 1 if((P1&0x78)!=0x78)
236 1 {
237 2 switch (P1&0x78)
238 2 {
239 3 case 0x38: result=1; break;
240 3 case 0x58: result=2; break;
241 3 case 0x68: result=3; break;
C51 COMPILER V7.06 COUNTER3 12/07/2006 03:10:11 PAGE 5
242 3 case 0x70: result=4; break;
243 3 default: result=0; break;
244 3 }
245 2 return result;
246 2 }
247 1 }
248 unsigned get_key(void)
249 {
250 1 unsigned char temp1,key_num=0;
251 1 unsigned char i=80;//按键时间
252 1 if((temp1=scan_key())!=0);
253 1 {
254 2 delay(100);//去抖动,可以适当改变
255 2 if(temp1==scan_key())
256 2 {
257 3 key_num=temp1;
258 3 while(scan_key()!=0&&i--)led_display();//放开按键或时间到都可以退出循环
259 3 }
260 2 }
261 1 return key_num;
262 1 }
263 //////////////////////////////////////////////////////////////////////////////////
264 void delay(unsigned int t)
265 {
266 1 unsigned int i;
267 1 for(i=0;i<t;i++)
268 1 ;
269 1 }
270 ///////////////////////////////////////////////////
271 void read_all(void)// EEPROM 高位在前面
272 {
273 1 unsigned char temp,i;
274 1 struct buff *temp_p;
275 1 temp_p=p;
276 1 p=count_buff;
277 1 for(i=6;i<26;i+=4,p++)
278 1 {
279 2 temp= x24c02_read(i);
280 2 p->count_num|=temp;
281 2 p->count_num<<=8;
282 2 temp= x24c02_read(i+1);
283 2 p->count_num|=temp;
284 2 p->count_num<<=8;
285 2 temp= x24c02_read(i+2);
286 2 p->count_num|=temp;
287 2 p->count_num<<=8;
288 2 temp= x24c02_read(i+3);
289 2 p->count_num|=temp;
290 2 }
291 1 p=temp_p;
292 1 count_buff[1].count_num=count_buff[2].count_num;
293 1
294 1
295 1
296 1 temp= x24c02_read(32);//fall high 8 bits
297 1 fall|=temp;
298 1 fall<<=8;
299 1 temp= x24c02_read(33);//fall low 8 bits
300 1 fall|=temp;
301 1
302 1 temp= x24c02_read(30);//rise high 8 bits
303 1 rise|=temp;
C51 COMPILER V7.06 COUNTER3 12/07/2006 03:10:11 PAGE 6
304 1 rise<<=8;
305 1 temp= x24c02_read(31);//rise low 8 bits
306 1 rise|=temp;
307 1 }
308 void write_all(void)
309 {
310 1 unsigned char temp,i;
311 1 unsigned long int k;
312 1 struct buff *temp_p;
313 1 temp_p=p;
314 1 p=count_buff;
315 1 for(i=10;i<27;i+=4,p++)
316 1 {
317 2 k=p->count_num;
318 2 temp=(unsigned char)k&0x000000ff;
319 2 x24c02_write(i+3, temp);
320 2 k>>=8;
321 2 temp=(unsigned char)k&0x000000ff;
322 2 x24c02_write(i+2, temp);
323 2 k>>=8;
324 2 temp=(unsigned char)k&0x000000ff;
325 2 x24c02_write(i+1, temp);
326 2 k>>=8;
327 2 temp=(unsigned char)k&0x000000ff;
328 2 x24c02_write(i, temp);
329 2 }
330 1 p=temp_p;
331 1 }
332
333 void write_fall(void)
334 {
335 1 unsigned char temp;
336 1 unsigned int k;
337 1 k=fall;
338 1 temp=(unsigned char)k&0x00ff;
339 1 x24c02_write(33, temp);//fall low 8 bits
340 1 k>>=8;
341 1 temp=(unsigned char)k&0x00ff;//fall high 8 bits
342 1 x24c02_write(32, temp);
343 1 }
344 void write_rise(void)
345 {
346 1 unsigned char temp;
347 1 unsigned int k;
348 1 k=rise;
349 1 temp=(unsigned char)k&0x00ff;
350 1 x24c02_write(31, temp);//rise low 8 bits
351 1 k>>=8;
352 1 temp=(unsigned char)k&0x00ff;//rise low 8 bits
353 1 x24c02_write(30, temp);
354 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1790 ----
CONSTANT SIZE = 13 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 60 32
IDATA SIZE = ---- ----
BIT SIZE = 2 ----
END OF MODULE INFORMATION.
C51 COMPILER V7.06 COUNTER3 12/07/2006 03:10:11 PAGE 7
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -