📄 4-2.lst
字号:
C51 COMPILER V6.12 4_2 11/22/2007 22:50:42 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE 4_2
OBJECT MODULE PLACED IN .\4-2.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE ..\..\lesson4\4-2\4-2.c BROWSE DEBUG OBJECTEXTEND PRINT(.\4-2.lst) OBJECT(.
-\4-2.obj)
stmt level source
1 #include<reg52.h>
2 #include<intrins.h>
3 #define uchar unsigned char
4 #define ul unsigned long
5
6 ul n;
7 sbit dula=P2^6;
8 sbit wela=P2^7;
9 sbit c_led=P2^5;
10 sbit beep=P2^3;
11 uchar led=0xfe;
12 uchar count_0,count_1,s;
13
14 uchar code tabledu[]={
15 0x3f,0x06,0x5b,0x4f,
16 0x66,0x6d,0x7d,0x07,
17 0x7f,0x6f,0x77,0x7c,
18 0x39,0x5e,0x79,0x71};
19
20 uchar code tabledu_0[]={
21 0xbf,0x86,0xdb,0xcf,
22 0xe6,0xed,0xfd,0x87,
23 0xff,0xef,0xf7,0xfc,
24 0xb9,0xde,0xf9,0xf1};
25
26 uchar code tablewe[]={
27 0x01,0x02,0x04,0x08,
28 0x10,0x20
29 };
30
31 void display(uchar,uchar,uchar,uchar,uchar,uchar);
32 void led_beep();
33 void delay(uchar);
34
35
36 void main()
37 {EA=1;
38 1 ET1=1;
39 1 ET0=1;
40 1 TMOD=0X11;
41 1 TH1=(65536-10000)/256;
42 1 TL1=(65536-10000)%256;
43 1 TH0=(65536-50000)/256;
44 1 TL0=(65536-50000)%256;
45 1 n=765432;
46 1 TR1=1;
47 1
48 1 while(1)
49 1 {
50 2 //------n decline and display the num;
51 2 if(count_1==1)
52 2 {count_1=0;
53 3 n--;
54 3 }
C51 COMPILER V6.12 4_2 11/22/2007 22:50:42 PAGE 2
55 2 display(n/100000,n%100000/10000,n%10000/1000,n%1000/100,n%100/10,n%10);
56 2
57 2 //------led shine
58 2 if(n<=764987&&TR0==0) TR0=1; // (&&TR0==0)can make this order run one time
59 2
60 2 if(count_0==20)
61 2 {
62 3 s=1;
63 3 count_0=0;
64 3 led=_crol_(led,1);
65 3 }
66 2 if(s==1) {led_beep() ;s=0; } // if count 0 interrupt one time ,then change the led;
67 2
68 2 } //while
69 1
70 1
71 1
72 1
73 1
74 1
75 1 }//main
76
77 void tim1() interrupt 3
78 {
79 1 TH1=(65536-10000)/256;
80 1 TL1=(65536-10000)%256;
81 1 count_1++;
82 1 }
83
84 void tim0() interrupt 1
85 {
86 1 TH0=(65536-50000)/256;
87 1 TL0=(65536-50000)%256;
88 1 count_0++;
89 1 }
90 void display(uchar w1,uchar w2,uchar w3,uchar w4,uchar w5,uchar w6)
91 {
92 1 P0=0x00;
93 1 wela=1;
94 1 wela=0;
95 1 P0=~tabledu[w1];
96 1 dula=1;
97 1 dula=0;
98 1 P0=tablewe[0];
99 1 wela=1;
100 1 wela=0;
101 1 delay(1);
102 1 //-------------------
103 1 P0=0x00;
104 1 wela=1;
105 1 wela=0;
106 1 P0=~tabledu[w2];
107 1 dula=1;
108 1 dula=0;
109 1 P0=tablewe[1];
110 1 wela=1;
111 1 wela=0;
112 1 delay(1);
113 1 //-------------------
114 1 P0=0x00;
115 1 wela=1;
116 1 wela=0;
C51 COMPILER V6.12 4_2 11/22/2007 22:50:42 PAGE 3
117 1 P0=~tabledu[w3];
118 1 dula=1;
119 1 dula=0;
120 1 P0=tablewe[2];
121 1 wela=1;
122 1 wela=0;
123 1 delay(1);
124 1 //-------------------
125 1 P0=0x00;
126 1 wela=1;
127 1 wela=0;
128 1 P0=~tabledu_0[w4]; // the fourth bit has the dot;
129 1 dula=1;
130 1 dula=0;
131 1 P0=tablewe[3];
132 1 wela=1;
133 1 wela=0;
134 1 delay(1);
135 1 //-------------------
136 1 P0=0x00;
137 1 wela=1;
138 1 wela=0;
139 1 P0=~tabledu[w5];
140 1 dula=1;
141 1 dula=0;
142 1 P0=tablewe[4];
143 1 wela=1;
144 1 wela=0;
145 1 delay(1);
146 1 //-------------------
147 1 P0=0x00;
148 1 wela=1;
149 1 wela=0;
150 1 P0=~tabledu[w6];
151 1 dula=1;
152 1 dula=0;
153 1 P0=tablewe[5];
154 1 wela=1;
155 1 wela=0;
156 1 delay(1);
157 1 }
158
159 void led_beep()
160 {uchar a,b;
161 1 for(a=3;a>0;a--)
162 1 {beep=~beep;for(b=15;b>0;b--);}
163 1
164 1 P1=led;
165 1 c_led=1;
166 1 c_led=0;
167 1
168 1 }
169 void delay(uchar x)
170 {
171 1 uchar a,b;
172 1 for(a=x;a>0;a--)
173 1 for(b=255;b>0;b--);
174 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 560 ----
C51 COMPILER V6.12 4_2 11/22/2007 22:50:42 PAGE 4
CONSTANT SIZE = 38 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 8 6
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -