📄 led-6.lst
字号:
C51 COMPILER V8.05a LED_6 12/08/2008 22:51:57 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE LED_6
OBJECT MODULE PLACED IN LED-6.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE LED-6.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /**************************
2 *module name:LED-6A *
3 *author:GYB *
4 *having copyright:RT *
5 ***************************/
6 #include<stdio.h>
7 #include<reg51.h>
8 #include<string.h>
9
10 #define Uchar unsigned char
11 #define Uint unsigned int
12
13 sfr WDTD = 0x85;
14 sfr WDTC = 0xC0;
15
16 /* control pin */
17 sbit s1=P3^1;
18 sbit s2=P3^2;
19 sbit s3=P3^3;
20 sbit s4=P3^4;
21 sbit s5=P3^5;
22
23 /* LED CONTROL*/
24 sbit L1=P1^5;
25 sbit L2=P1^4;
26 sbit L3=P1^3;
27 sbit L4=P1^2;
28 sbit L5=P1^1;
29 sbit L6=P1^0;
30
31 /*蜂鸣器、消音、试灯*/
32 sbit mute=P1^7;
33 sbit test=P1^6;
34 sbit buzz=P3^0;
35 sbit KA1=P3^7;
36
37 /*消音标志位*/
38 unsigned char bdata Mute1;
39 sbit dis1=Mute1^0;
40 sbit dis2=Mute1^1;
41 sbit dis3=Mute1^2;
42 sbit dis4=Mute1^3;
43 sbit dis5=Mute1^4;
44
45
46 /*状态标志位*/
47 unsigned char bdata state1;
48 sbit st1=state1^0;
49 sbit st2=state1^1;
50 sbit st3=state1^2;
51 sbit st4=state1^3;
52 sbit st5=state1^4;
53
54 /*闪光标志*/
55 unsigned char bdata led;
C51 COMPILER V8.05a LED_6 12/08/2008 22:51:57 PAGE 2
56 sbit flash=led^0;
57 sbit dis =led^1;
58 sbit light=led^2;
59
60
61 unsigned char n1,n2,n3,n4,n5,n10,n11,n12,m1;
62
63 void begin(void)
64 {
65 1
66 1 TMOD = 0x01; /*set T0 to Hex counter*/
67 1 SCON=0; /*mode 0*/
68 1 EA = 1;
69 1 ET0=1; /*T0 Enable*/
70 1 TR0 = 1;
71 1 WDTD=0x80; //装入重装载值
72 1 WDTC=0x09; //启动看门狗定时器,使能看门狗定时器复位
73 1
74 1 }
75
76
77 void intt0(void) interrupt 1
78 {
79 1 m1++;
80 1 if(m1==7)
81 1 {flash=!flash;m1=0;}
82 1
83 1 /*1*/
84 1
85 1 if(!s1)
86 1 {n1++;
87 2 if(n1>5)
88 2 {st1=1;n1=5;}
89 2 }
90 1 else
91 1 {n1=0;st1=0;dis1=0;}
92 1
93 1
94 1 /*2*/
95 1 if(!s2)
96 1 {n2++;
97 2 if(n2>5)
98 2 {st2=1;n2=5;}
99 2 }
100 1 else
101 1 {n2=0;st2=0;dis2=0;}
102 1
103 1 /*3*/
104 1 if(!s3)
105 1 {n3++;
106 2 if(n3>5)
107 2 {st3=1;n3=5;}
108 2 }
109 1 else
110 1 {n3=0;st3=0;dis3=0;}
111 1
112 1 /*4*/
113 1 if(!s4)
114 1 {n4++;
115 2 if(n4>5)
116 2 {st4=1;n4=5;}
117 2 }
C51 COMPILER V8.05a LED_6 12/08/2008 22:51:57 PAGE 3
118 1 else
119 1 {n4=0;st4=0;dis4=0;}
120 1
121 1 /*5*/
122 1 if(!s5)
123 1 {n5++;
124 2 if(n5>5)
125 2 {st5=1;n5=5;}
126 2 }
127 1 else
128 1 {n5=0;st5=0;dis5=0;}
129 1
130 1
131 1 if(!mute) //消音
132 1 {n10++;
133 2 if(n10>2)
134 2 {dis=1;n10=0;}
135 2 }
136 1
137 1
138 1 if(!test) //试灯
139 1 {n11++;
140 2 if(n11>2)
141 2 {light=1;n11=0;}
142 2 }
143 1 else {light=0;n11=0;}
144 1
145 1
146 1
147 1 }
148
149
150 void watchdog() //喂狗子程序
151 {
152 1 WDTD=0x80; //看门狗装入重装载值
153 1 WDTC = WDTC|0x02; //执行装载指令
154 1 }
155
156 void main(void)
157 {
158 1 begin();
159 1 watchdog();
160 1 while(1)
161 1 { watchdog();
162 2 L1=0;
163 2 L2= (!((st1&dis1)|(st1&flash))&(!light)); //灯的控制
164 2 L3= (!((st2&dis2)|(st2&flash))&(!light));
165 2 L4= (!((st3&dis3)|(st3&flash))&(!light));
166 2 L5= (!((st4&dis4)|(st4&flash))&(!light));
167 2 L6= (!((st5&dis5)|(st5&flash))&(!light));
168 2
169 2 if(st1||st2||st3||st4||st5)
170 2 KA1=0;
171 2 else KA1=1;
172 2
173 2 if(dis) //消音
174 2 {dis1=st1;
175 3 dis2=st2;
176 3 dis3=st3;
177 3 dis4=st4;
178 3 dis5=st5;
179 3 dis=0;
C51 COMPILER V8.05a LED_6 12/08/2008 22:51:57 PAGE 4
180 3 n10=0;
181 3 }
182 2
183 2 if((dis1==st1)&(dis2==st2)&(dis3==st3)&(dis4==st4)&(dis5==st5)) //蜂鸣器
184 2 buzz=1;
185 2 else
186 2 buzz=!flash;
187 2
188 2 }
189 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 456 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 12 ----
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 + -