line level source
1 #include<reg52.h>
2 #include<math.h>
3 #define uchar unsigned char
4 #define uint unsigned int
5 #define lon long int
6 lon sd;
7 uint count;
8 uint disnum;
9 sbit dula=P2^6;
10 sbit wela=P2^7;
11 uchar code tabledu[]={
12 0x3f,0x06,0x5b,0x4f,
13 0x66,0x6d,0x7d,0x07,
14 0x7f,0x6f,0x77,0x7c,
15 0x39,0x5e,0x79,0x71};
16 display(uchar,uchar,uchar,uchar);
17 delay(uchar);
18 void main()
19 {
20 1 EA=1;
21 1 EX0=1;
22 1 EX1=1;
23 1 IT0=1;
24 1 IT1=1;
25 1 ET1=1;
26 1 TMOD=0x11;
27 1 TH1=(65536-1000)/256;
28 1 TL1=(65536-1000)%256;
29 1
30 1 //pd=0;
31 1 count=0;
32 1 while(1)
33 1 {
34 2 //if (count==999);
35 2
36 2 //{display(999/100,999%100/10,999%100%10);}
37 2 //display(count/100,count%100/10,count%100%10);
38 2 display(count/1000,count%1000/100,count%1000%100/10,count%1000%100%10);
39 2 }
40 1 }
41
42 void ext0() interrupt 0 using 1
43 {
44 1 TR1=0;
45 1 EX0=0;
46 1 count=count;
47 1 sd=0.5/(count*1085/1000/1000);
48 1 //count=fabs(sd);
49 1
50 1 }
51 void ext1() interrupt 2 using 2
52 {
53 1 EX1=0;
54 1 //count=1111;
55 1 TR1=1;
C51 COMPILER V7.10 TEST6 05/10/2009 18:35:53 PAGE 2
56 1 //pd=0;
57 1 //count=0.5/(count*1085/1000/1000);
58 1
59 1 }
60 void tim1() interrupt 3 using 3
61 {
62 1 TH1=(65536-1000)/256;
63 1 TL1=(65536-1000)%256;
64 1 count++;
65 1 }
66
67 display(uchar qian,uchar bai,uchar shi,uchar ge)
68 {
69 1
70 1 P0=tabledu[qian];
71 1 dula=1;
72 1 dula=0;
73 1 P0=0xfe;
74 1 wela=1;
75 1 wela=0;
76 1 delay(2);
77 1
78 1
79 1 P0=tabledu[bai];
80 1 dula=1;
81 1 dula=0;
82 1 P0=0xfd;
83 1 wela=1;
84 1 wela=0;
85 1 delay(2);
86 1
87 1
88 1 P0=tabledu[shi];
89 1 dula=1;
90 1 dula=0;
91 1 P0=0xfb;
92 1 wela=1;
93 1 wela=0;
94 1 delay(2);
95 1
96 1 P0=tabledu[ge];
97 1 dula=1;
98 1 dula=0;
99 1 P0=0xf7;
100 1 wela=1;
101 1 wela=0;
102 1 delay(2);
103 1 }
104 delay(uchar x)
105 {
106 1 uchar a,b;
107 1 for(a=x;a>0;a--)
108 1 for(b=255;b>0;b--);
109 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 373 ----
CONSTANT SIZE = 16 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 8 4
C51 COMPILER V7.10 TEST6 05/10/2009 18:35:53 PAGE 3
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)