📄 yinyue.lst
字号:
C51 COMPILER V7.08 YINYUE 09/29/2006 21:30:15 PAGE 1
C51 COMPILER V7.08, COMPILATION OF MODULE YINYUE
OBJECT MODULE PLACED IN yinyue.OBJ
COMPILER INVOKED BY: c:\Keil\C51\BIN\C51.EXE yinyue.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /******************************************************************************
2 *
3 * pm5050语音遥控输出程序 *
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 1 //0.2S
16 #define highshorttime 1 //0.5S
17 #define highlongtime 5 //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 outspk_ctr (unsigned char partnum);
33 void readkey (void);
34 void Count_S(void);
35
36 /* STC89C52RC内部EEPROM:END */
37
38 /******************************************************************************
39 * 定义全局变量 *
40 * *
41 * 空间名称 地址范围 说明 *
42 * DATA D:00H-D:7FH 片内RAM直接寻址区 *
43 * BDATA D:20H-D:2FH 片内RAM位寻址区 *
44 * IDATA I:00H-I:FFH 片内RAM间接寻址区 *
45 * XDATA X:0000H-X:FFFFH 64KB常规片外RAM数据区 *
46 * CODE C:0000H-C:FFFFH 64KB常规片外ROM代码区 *
47 ******************************************************************************/
48
49 unsigned char bdata highkeyflgshort,highkeyflglong;//input station var
50 sbit highkeyflgshort_A = highkeyflgshort^0;
51 sbit highkeyflgshort_B = highkeyflgshort^1;
52 sbit highkeyflgshort_C = highkeyflgshort^2;
53 sbit highkeyflgshort_D = highkeyflgshort^3;
54
55 sbit highkeyflglong_A = highkeyflglong^0;
C51 COMPILER V7.08 YINYUE 09/29/2006 21:30:15 PAGE 2
56 sbit highkeyflglong_B = highkeyflglong^1;
57 sbit highkeyflglong_C = highkeyflglong^2;
58 sbit highkeyflglong_D = highkeyflglong^3;
59 sbit busy_01 = highkeyflglong^4;
60 sbit play_busy = highkeyflglong^5;
61
62 /* 定义单片机管脚 */
63 sbit in_key_A = P3^2;
64 sbit in_key_B = P3^3;
65 sbit in_key_C = P3^4;
66 sbit in_key_D = P3^5;
67
68 sbit res = P1^3;
69 sbit in_spk_01 = P3^7;
70 sbit out_spk_k1 = P1^7;
71 sbit out_spk_k2 = P1^6;
72
73 sbit out_power_12v = P1^4;
74 //sbit out_led_D1 = P3^7;
75 sbit out_led_D2 = P3^1;
76
77
78 /* 主程序 */
79 void main (void)
80 {
81 1
82 1
83 1 P1 = 0xFF; // 端口初始化
84 1 P3 = 0xFF;
85 1 highkeyflgshort = 0;
86 1 highkeyflglong = 0;
87 1 // 主程序初始化
88 1 for ( ; ; )
89 1 {
90 2 readkey ();
91 2
92 2
93 2 //if((in_key_A&&in_key_B&&in_key_C&&in_key_D)==1)out_power_12v = 0;//开工
94 2
95 2 //if((play_busy==0)&&(in_spk_01==0)) out_power_12v = 1 ,play_busy=0;//关工放
96 2 //if (play_busy==0) out_power_12v = 1 ;
97 2 // else out_power_12v = 0 ;
98 2
99 2
100 2 //if (play_busy==0 ?) out_power_12v = 1;out_power_12v = 0;
101 2 Count_S();
102 2
103 2
104 2 if (highkeyflgshort != 0x0)//if 1
105 2 {
106 3 switch (highkeyflgshort)//highkeyflgshort//switch 1
107 3 {
108 4
109 4 case 0x01: outspk_ctr(0x00);//S_A
110 4 break;
111 4 case 0x02: outspk_ctr(0x01);//S_B
112 4 break;
113 4 case 0x04: outspk_ctr(0x02);//S_C
114 4 break;
115 4 case 0x08: outspk_ctr(0x03);//S_D
116 4 break;
117 4
C51 COMPILER V7.08 YINYUE 09/29/2006 21:30:15 PAGE 3
118 4 default: delayNms (100);//保证时基的均匀
119 4 break;
120 4 }//switch 1 end
121 3
122 3 highkeyflgshort = highkeyflgshort & 0xf0;//得到有效按键,只播放一次,故要清掉
123 3 }
124 2 else
125 2 { if ((highkeyflglong & 0x0f) != 0x0)//if 2
126 3 {
127 4 switch ((highkeyflglong & 0x0f))//highkeyflgshort
128 4 {//switch 2
129 5
130 5 case 0x03: outspk_ctr(0x04);//L_A+B
131 5 break;
132 5 case 0x0c: outspk_ctr(0x05);//L_C+D
133 5 break;
134 5 case 0x01: outspk_ctr(0x06);//L_A
135 5 break;
136 5 case 0x02: outspk_ctr(0x07);//L_B
137 5 break;
138 5 case 0x04: outspk_ctr(0x08);//L_C
139 5 break;
140 5 case 0x08: outspk_ctr(0x09);//L_D
141 5 break;
142 5
143 5 default: delayNms (100);//保证时基的均匀
144 5 break;
145 5 }//switch 2 end
146 4 highkeyflglong =highkeyflglong & 0xf0;//得到有效按键,只播放一次,故要清掉
147 4 }// if 2 end
148 3 else//未进入两个SWITCH
149 3 delayNms (100);//保证时基的均匀
150 3 if (in_spk_01== 0) out_power_12v = 1;
151 3
152 3
153 3 }//if 1 else is end
154 2
155 2 } //for end
156 1
157 1
158 1 }//main end
159
160 /****************************************************************/
161 void readkey (void) //扫描时间较确定
162 {
163 1
164 1 /**************************in_key_A*******************************/
165 1 if (in_key_A)
166 1 { highkeycount_A++;}
167 1 else
168 1 { /*
169 2 if ( highkeycount_A < highfiltertime ) //无效输入
170 2
171 2 {
172 2 highkeyflglong_A = 0;
173 2 highkeyflgshort_A = 0;
174 2 }
175 2 else
176 2 { */
177 2 if(highkeycount_A>0)
178 2 {
179 3
C51 COMPILER V7.08 YINYUE 09/29/2006 21:30:15 PAGE 4
180 3
181 3 if ( highkeycount_A > highlongtime )//长信号
182 3
183 3 { highkeyflglong_A = 1;
184 4 highkeyflgshort_A = 0;
185 4 }
186 3 else
187 3 { /*if ( (highkeycount_A < highshorttime) && (highkeycount_A > highfiltertime)) //短信号
188 4 {*/
189 4 highkeyflgshort_A = 1;
190 4 highkeyflglong_A = 0;
191 4 }
192 3 // }
193 3 }
194 2
195 2 highkeycount_A = 0; //计数清零
196 2 }
197 1 /****************************in_key_B*****************************/
198 1 if (in_key_B)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -