📄 40w.lst
字号:
C51 COMPILER V7.08 40W 09/30/2006 21:14:41 PAGE 1
C51 COMPILER V7.08, COMPILATION OF MODULE 40W
OBJECT MODULE PLACED IN 40w.OBJ
COMPILER INVOKED BY: c:\Keil\C51\BIN\C51.EXE 40w.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /******************************************************************************
2 *
3 * pm5050语音遥控输出程序 40w *
4 * 单片机 AT89C2051 *
5 * 功放为TDA2003 *
6 * 设计:叶设炉 *
7 * 时间:2006年9月24日完成 *
8 * *
9 ******************************************************************************/
10
11 /* 加载头文件 */
12 #include <reg52.h>
13 #include <intrins.h>
14 /*定义宏变量*/
15 #define highfiltertime 0 //0.2S
16 #define highshorttime 1 //0.5S
17 #define highlongtime 10 //1S
18
19 /* 定义全局变量 */
20 unsigned long highkeycount_A;
21 unsigned long highkeycount_B;
22 unsigned long highkeycount_C;
23 unsigned long highkeycount_D;
24
25 unsigned long s_count;
26 unsigned long s10_count;
27
28
29 /* 子函数声明 */
30
31 void delayNms (unsigned long partnumx);
32 void outkey (unsigned char partnum);
33 void readkey (void);
34 void o1 (void);
35 void o2 (void);
36 void o3 (void);
37 void o4 (void);
38 void o5 (void);
39 void o6 (void);
40 void o7 (void);
41 void o8 (void);
42
43 void Count_S(void);
44
45 /* STC89C52RC内部EEPROM:END */
46
47 /******************************************************************************
48 * 定义全局变量 *
49 * *
50 * 空间名称 地址范围 说明 *
51 * DATA D:00H-D:7FH 片内RAM直接寻址区 *
52 * BDATA D:20H-D:2FH 片内RAM位寻址区 *
53 * IDATA I:00H-I:FFH 片内RAM间接寻址区 *
54 * XDATA X:0000H-X:FFFFH 64KB常规片外RAM数据区 *
55 * CODE C:0000H-C:FFFFH 64KB常规片外ROM代码区 *
C51 COMPILER V7.08 40W 09/30/2006 21:14:41 PAGE 2
56 ******************************************************************************/
57
58 unsigned char bdata highkeyflgshort,highkeyflglong;//input station var
59 sbit highkeyflgshort_A = highkeyflgshort^0;
60 sbit highkeyflgshort_B = highkeyflgshort^1;
61 sbit highkeyflgshort_C = highkeyflgshort^2;
62 sbit highkeyflgshort_D = highkeyflgshort^3;
63
64 sbit highkeyflglong_A = highkeyflglong^0;
65 sbit highkeyflglong_B = highkeyflglong^1;
66 sbit highkeyflglong_C = highkeyflglong^2;
67 sbit highkeyflglong_D = highkeyflglong^3;
68 sbit busy_01 = highkeyflglong^4;
69 sbit play_busy = highkeyflglong^5;
70
71 /* 定义单片机管脚 */
72 sbit in_key_A = P3^2;
73 sbit in_key_B = P3^3;
74 sbit in_key_C = P3^4;
75 sbit in_key_D = P3^5;
76
77
78 sbit in_spk_01 = P3^7;
79 sbit k1 = P1^7;
80 sbit k2 = P1^6;
81 sbit k3 = P1^5;
82 sbit k4 = P1^4;
83 sbit k5 = P1^3;
84 sbit k6 = P1^2;
85 sbit k7 = P1^1;
86 sbit k8 = P1^0;
87
88 sbit out_led_D2 = P3^1;
89
90
91 /* 主程序 */
92 void main (void)
93 {
94 1
95 1
96 1 P1 = 0xFF; // 端口初始化
97 1 P3 = 0xFF;
98 1 highkeyflgshort = 0;
99 1 highkeyflglong = 0;
100 1 // 主程序初始化
101 1 for ( ; ; )
102 1 {
103 2 readkey ();
104 2
105 2
106 2 //if((in_key_A&&in_key_B&&in_key_C&&in_key_D)==1)out_power_12v = 0;//开工
107 2
108 2 //if((play_busy==0)&&(in_spk_01==0)) out_power_12v = 1 ,play_busy=0;//关工放
109 2 //if (play_busy==0) out_power_12v = 1 ;
110 2 // else out_power_12v = 0 ;
111 2
112 2
113 2 //if (play_busy==0 ?) out_power_12v = 1;out_power_12v = 0;
114 2 Count_S();
115 2
116 2
117 2 if (highkeyflgshort != 0x0)//if 1
C51 COMPILER V7.08 40W 09/30/2006 21:14:41 PAGE 3
118 2 {
119 3 switch (highkeyflgshort)//highkeyflgshort//switch 1
120 3 {
121 4
122 4 case 0x01: o1();//S_A
123 4 break;
124 4 case 0x02: o2();//S_B
125 4 break;
126 4 case 0x04: o3();//S_C
127 4 break;
128 4 case 0x08: o4();//S_D
129 4 break;
130 4
131 4 default: delayNms (50);//保证时基的均匀
132 4 break;
133 4 }//switch 1 end
134 3
135 3 highkeyflgshort = highkeyflgshort & 0xf0;//得到有效按键,只播放一次,故要清掉
136 3 }
137 2 else
138 2 { if ((highkeyflglong & 0x0f) != 0x0)//if 2
139 3 {
140 4 switch ((highkeyflglong & 0x0f))//highkeyflgshort
141 4 {//switch 2
142 5
143 5 // case 0x03: outkey(K5);//L_A+B
144 5 // break;
145 5 // case 0x0c: outkey(K6);//L_C+D
146 5 // break;
147 5 case 0x01: o5();//L_A
148 5 break;
149 5 case 0x02: o6();//L_B
150 5 break;
151 5 case 0x04: o7();//L_C
152 5 break;
153 5 case 0x08: o8();//L_D
154 5 break;
155 5
156 5 default: delayNms (50);//保证时基的均匀
157 5 break;
158 5 }//switch 2 end
159 4 highkeyflglong =highkeyflglong & 0xf0;//得到有效按键,只播放一次,故要清掉
160 4 }// if 2 end
161 3 else//未进入两个SWITCH
162 3 delayNms (100);//保证时基的均匀
163 3 // if (in_spk_01== 0) out_power_12v = 1;
164 3
165 3
166 3 }//if 1 else is end
167 2
168 2 } //for end
169 1
170 1
171 1 }//main end
172
173 /****************************************************************/
174 void readkey (void) //扫描时间较确定
175 {
176 1
177 1 /**************************in_key_A*******************************/
178 1 if (in_key_A) //如果A按下
179 1 { highkeycount_A++;} //时间累积
C51 COMPILER V7.08 40W 09/30/2006 21:14:41 PAGE 4
180 1 else
181 1 {
182 2 /* if ( highkeycount_A < highfiltertime ) //无效输入
183 2
184 2 {
185 2 highkeyflglong_A = 0;
186 2 highkeyflgshort_A = 0;
187 2 }
188 2 else
189 2 { */
190 2 if(highkeycount_A>0)
191 2 {
192 3
193 3
194 3 if ( highkeycount_A > highlongtime )//长信号
195 3
196 3 { highkeyflglong_A = 1;
197 4 highkeyflgshort_A = 0;
198 4 }
199 3 else
200 3 { /*if ( (highkeycount_A < highshorttime) && (highkeycount_A > highfiltertime)) //短信号
201 4 {*/
202 4 highkeyflgshort_A = 1;
203 4 highkeyflglong_A = 0;
204 4 }
205 3 // }
206 3 }
207 2
208 2 highkeycount_A = 0; //计数清零
209 2 }
210 1 /****************************in_key_B*****************************/
211 1 if (in_key_B)
212 1 { highkeycount_B++;}
213 1 else
214 1 {
215 2 /*if ( highkeycount_B < highfiltertime ) //无效输入
216 2
217 2 {
218 2 highkeyflglong_B = 0;
219 2 highkeyflgshort_B = 0;
220 2 }
221 2 else
222 2 {
223 2 */
224 2 if(highkeycount_B>0)
225 2 {
226 3
227 3 if ( highkeycount_B > highlongtime )//长信号
228 3
229 3 { highkeyflglong_B = 1;
230 4 highkeyflgshort_B = 0;
231 4 }
232 3 else
233 3 { /*if ( (highkeycount_B < highshorttime) && (highkeycount_B > highfiltertime)) //短信号
234 4 {*/
235 4 highkeyflgshort_B = 1;
236 4 highkeyflglong_B = 0;
237 4 // }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -