?? 1602.lst
字號:
249 1 while(bytes!=1)
250 1 {
251 2 *RamAddress=Read8Bit();
252 2 Ack();
253 2 RamAddress++;
254 2 bytes--;
255 2 }
256 1 *RamAddress=Read8Bit();
257 1 NoAck();
258 1 Stop();
259 1 }
260
261 /***************************************************************************/
262 void readmemory(void)
263 {
264 1 Read24c02(&bufs[0],adder[line],8);
265 1 day=bufs[0];
266 1 hour=bufs[1];
267 1 minite=bufs[2];
268 1 second=bufs[3];
269 1 number=bufs[4];
270 1 shiwan=bufs[5];
271 1 qian=bufs[6];
272 1 shi=bufs[7];
273 1 }
274
275 void t0(void) interrupt 1 using 0
276 {
277 1 unsigned int tcnt,count;
278 1 unsigned char half_sec;
279 1 ++tcnt;
280 1 ++count;
281 1 if(count==200)
282 1 { count=0;
283 2 ++half_sec;
284 2 if(half_sec==number)
285 2 {half_sec=0;P2_7=~P2_7;}
286 2 }
287 1 if(tcnt==400)
288 1 {
289 2 tcnt=0;
290 2 ++second;
291 2 if(second==60)
292 2 {
293 3 second=0;
294 3 ++minite;
295 3 if(minite==60)
296 3 {
297 4 minite=0;
298 4 ++hour;
299 4 if(hour==24)
300 4 {
301 5 hour=0;
302 5 ++day;
303 5 }
C51 COMPILER V7.07 1602 03/16/2009 11:13:25 PAGE 6
304 4 }
305 3 }
306 2 }
307 1 }
308
309 void getkey(void)
310
311 {
312 1 unsigned char k;
313 1 k=P3&0xf3;
314 1 if(k!=0xf3)
315 1 {
316 2 delay(2);if(k!=0xf3)
317 2 {
318 3 if(P3_0==0)
319 3 {
320 4 flag1=1; flag2=0; TR0=0;
321 4 }
322 3 if(P3_1==0)
323 3 {
324 4 flag1=0; flag2=1; TR0=0;readmemory();
325 4 }
326 3 if(P3_4==0)
327 3 {
328 4 flag2=0;TR0=0;
329 4 Write24c02(&bufss[0],0x0,16);
330 4 Write24c02(&bufss[0],0x10,16);
331 4 Write24c02(&bufss[0],0x20,16);
332 4 Write24c02(&bufss[0],0x30,16);
333 4 Write24c02(&bufss[0],0x40,16);
334 4 while(P3_4==0);
335 4 }
336 3
337 3 if(P3_5==0)
338 3 {
339 4 if(flag1){number++;if(number==99)number=98;}
340 4 if(flag2){line++;if(line==9)line=1;readmemory();}
341 4 while(P3_5==0);
342 4 }
343 3 if(P3_6==0)
344 3 {
345 4 if(flag1){number--;if(number==0)number=1;}
346 4 if(flag2){line--;if(line==0)line=8;readmemory();}
347 4 while(P3_6==0);
348 4 }
349 3 if(P3_7==0)
350 3 {
351 4 TR0=1;flag2=0;
352 4 }
353 3
354 3 }
355 2 }
356 1 }
357 void it0(void) interrupt 0
358 {
359 1 ++shi;
360 1 if(shi==100)
361 1 {
362 2 shi=0;
363 2 ++qian;
364 2 if(qian==100)
365 2 {
C51 COMPILER V7.07 1602 03/16/2009 11:13:25 PAGE 7
366 3 qian=0;
367 3 ++shiwan;
368 3 }
369 2 }
370 1 }
371
372 void display(void)
373 {
374 1 unsigned char i;
375 1 buffer[11]=tab[second%10];
376 1 buffer[10]=tab[second/10];
377 1 buffer[8]=tab[minite%10];
378 1 buffer[7]=tab[minite/10];
379 1 buffer[5]=tab[hour%10];
380 1 buffer[4]=tab[hour/10];
381 1 buffer[1]=tab[day%10];
382 1 if(day>9)buffer[0]=tab[day/10];
383 1 else buffer[0]=' ';
384 1 GotoXY(4,0);
385 1 Print(&buffer[0]);
386 1
387 1 if(number>9)
388 1 num[0]=tab[number/10];else num[0]=' ';
389 1 num[1]=tab[number%10];
390 1 GotoXY(0,1);//
391 1 Print(&num[0]);
392 1
393 1 buf[0]=tab[shiwan/10];
394 1 buf[1]=tab[shiwan%10];
395 1 buf[2]=tab[qian/10];
396 1 buf[3]=tab[qian%10];
397 1 buf[4]=tab[shi/10];
398 1 buf[5]=tab[shi%10];
399 1 for(i=0;(buf[i]=='0'||buf[i]==' ')&& i!=5; i++)
400 1 buf[i]=' ';
401 1 GotoXY(7,1);
402 1 Print(&buf[0]);
403 1
404 1 if(flag2) {buff[0]='L';buff[1]=tab[line];}
405 1 else {buff[0]=' ';buff[1]=' ';}
406 1 GotoXY(14,1);
407 1 Print(&buff[0]);
408 1 }
409 void init(void)
410 {
411 1 TMOD=0x2;
412 1 TH0=0x06;
413 1 TL0=0x06;
414 1 EX0=1;
415 1 TR0=0;
416 1 ET0=1;
417 1 IT0=1;
418 1 EA=1;
419 1 LCD_Initial();
420 1 GotoXY(0,0);
421 1 Print(" day ");
422 1 GotoXY(0,1);
423 1 Print(" s/t 0 ");
424 1 }
425
426
427 void test(void)
C51 COMPILER V7.07 1602 03/16/2009 11:13:25 PAGE 8
428 {
429 1 if(P1!=q)
430 1 {
431 2 delay(2);
432 2 if(P1!=q)
433 2 {
434 3 q=P1;
435 3 bufs[0]=day;
436 3 bufs[1]=hour;
437 3 bufs[2]=minite;
438 3 bufs[3]=second;
439 3 bufs[4]=number;
440 3 bufs[5]=shiwan;
441 3 bufs[6]=qian;
442 3 bufs[7]=shi;
443 3 if(P1_0)
444 3 {
445 4 if(f0){Write24c02(&bufs[0],0x08,8);f0=0;}
446 4 }
447 3
448 3 if(P1_1)
449 3 {
450 4 if(f1){Write24c02(&bufs[0],0x10,8);f1=0;}
451 4 }
452 3 if(P1_2)
453 3 {
454 4 if(f2){Write24c02(&bufs[0],0x18,8);f2=0;}
455 4 }
456 3 if(P1_3)
457 3 {
458 4 if(f3){Write24c02(&bufs[0],0x20,8);f3=0;}
459 4 }
460 3 if(P1_4)
461 3 {
462 4 if(f4){Write24c02(&bufs[0],0x28,8);f4=0;}
463 4 }
464 3
465 3 if(P1_5)
466 3 {
467 4 if(f5){Write24c02(&bufs[0],0x30,8);f5=0;}
468 4 }
469 3 if(P1_6)
470 3 {
471 4 if(f6){Write24c02(&bufs[0],0x38,8);f6=0;}
472 4 }
473 3
474 3 if(P1_7)
475 3 {
476 4 if(f7){Write24c02(&bufs[0],0x40,8);f7=0;}
477 4 }
478 3 }
479 2 }
480 1 }
481 main()
482 {
483 1 init();
484 1 while(1)
485 1 {
486 2 display();
487 2 getkey();
488 2 test();
489 2 }
C51 COMPILER V7.07 1602 03/16/2009 11:13:25 PAGE 9
490 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1359 ----
CONSTANT SIZE = 44 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 77 16
IDATA SIZE = ---- ----
BIT SIZE = 10 2
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -