时钟计时器
源代码在线查看: 电子时钟.lst
C51 COMPILER V7.06 _缱邮_钟 05/17/2008 08:24:57 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE _缱邮_钟
OBJECT MODULE PLACED IN 电子时钟.OBJ
COMPILER INVOKED BY: F:\keil C51\C51\BIN\C51.EXE 电子时钟.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include
2 #define uint unsigned int
3 #define uchar unsigned char
4
5 sbit L1=P2^0;sbit L2=P2^1;
6
7 uchar s=0,m=0,n=0,h=0,k=0,y=0,u=0;
8 uchar table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
9 void delay(uint i)
10 {
11 1 uint j;
12 1 for(;i 13 1 for(j=110;j 14 1 }
15
16
17 void main()
18 {
19 1
20 1 EA=1;ET0=1;TMOD=0x01;
21 1 TH0=(65536-10000)/256;
22 1 TL0=(65536-10000)%256;
23 1 TR0=1;
24 1
25 1 while(1)
26 1 {
27 2
28 2 P1=table[m];P2=0x3e;delay(20);
29 2 P2=0x3f;
30 2 P1=table[n];P2=0x3d;delay(20);
31 2 P2=0x3f;
32 2 P1=table[h];P2=0x3b;delay(20);
33 2 P2=0x3f;
34 2 P1=table[k];P2=0x37;delay(20);
35 2 P2=0x3f;
36 2 P1=table[y];P2=0x2f;delay(20);
37 2 P2=0x3f;
38 2 P1=table[u];P2=0x1f;delay(20);
39 2 P2=0x3f;
40 2 if(u==2&y==4)
41 2 {
42 3 m=0;n=0;h=0;k=0;y=0;u=0;
43 3 }
44 2 }
45 1
46 1
47 1 }
48
49
50
51 void timer0(void) interrupt 1
52 {
53 1 TH0=(65536-10000)/256;
54 1 TL0=(65536-10000)%256;
55 1 s++;
C51 COMPILER V7.06 _缱邮_钟 05/17/2008 08:24:57 PAGE 2
56 1 if(s==100)
57 1 {
58 2 m++;s=0;
59 2 if(m==10)
60 2 {
61 3 n++;
62 3 m=0;
63 3 if(n==6)
64 3 {
65 4 h++;n=0;
66 4 if(h==10)
67 4 {
68 5 k++,h=0;
69 5 if(k==6)
70 5 {
71 6 y++,k=0;
72 6 if(y==10)
73 6 {
74 7 u++,y=0;
75 7
76 7 }
77 6 }
78 5 }
79 4 }
80 3
81 3 }
82 2 }
83 1
84 1
85 1
86 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 271 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 17 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)