📄 ok.lst
字号:
C51 COMPILER V7.08 OK 12/03/2006 10:17:14 PAGE 1
C51 COMPILER V7.08, COMPILATION OF MODULE OK
OBJECT MODULE PLACED IN OK.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE OK.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /******************************************************************************
2 *
3 * pm5050语音遥控输出程序 40w *
4 * 单片机 AT89C2051 *
5 * 功放为TDA2003 *
6 * 设计:叶设炉 *
7 * 时间:2006年10月25日完成 *
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
46 unsigned char bdata highkeyflgshort,highkeyflglong;//input station var
47 sbit highkeyflgshort_A = highkeyflgshort^0;
48 sbit highkeyflgshort_B = highkeyflgshort^1;
49 sbit highkeyflgshort_C = highkeyflgshort^2;
50 sbit highkeyflgshort_D = highkeyflgshort^3;
51
52 sbit highkeyflglong_A = highkeyflglong^0;
53 sbit highkeyflglong_B = highkeyflglong^1;
54 sbit highkeyflglong_C = highkeyflglong^2;
55 sbit highkeyflglong_D = highkeyflglong^3;
C51 COMPILER V7.08 OK 12/03/2006 10:17:14 PAGE 2
56 sbit busy_01 = highkeyflglong^4;
57 sbit play_busy = highkeyflglong^5;
58
59 /* 定义单片机管脚 */
60 sbit in_key_A = P3^2;
61 sbit in_key_B = P3^3;
62 sbit in_key_C = P3^4;
63 sbit in_key_D = P3^5;//11000011
64
65
66 sbit in_spk_01 = P3^7;
67 sbit k1 = P1^7;
68 sbit k2 = P1^6;
69 sbit k3 = P1^5;
70 sbit k4 = P1^4;
71 sbit k5 = P1^3;
72 sbit k6 = P1^2;
73 sbit k7 = P1^1;
74 sbit k8 = P1^0;
75
76 sbit out_led_D2 = P3^1;
77
78
79 /* 主程序 */
80 void main (void)
81 {
82 1
83 1
84 1 P1 = 0xFF; // 端口初始化
85 1 P3 = 0xFF;
86 1 highkeyflgshort = 0;
87 1 highkeyflglong = 0;
88 1 // 主程序初始化
89 1 for ( ; ; )
90 1 {
91 2 readkey ();
92 2
93 2 Count_S();
94 2
95 2
96 2 if (highkeyflgshort != 0x0)//if 1
97 2 {
98 3 switch (highkeyflgshort)//highkeyflgshort//switch 1
99 3 {
100 4
101 4 case 0x01: o1();//S_A
102 4 break;
103 4 case 0x02: o2();//S_B
104 4 break;
105 4 case 0x04: o3();//S_C
106 4 break;
107 4 case 0x08: o4();//S_D
108 4 break;
109 4
110 4 default: delayNms (30);//保证时基的均匀
111 4 break;
112 4 }//switch 1 end
113 3
114 3 highkeyflgshort = highkeyflgshort & 0xf0;//得到有效按键,只播放一次,故要清掉
115 3 }
116 2 else
117 2 { if ((highkeyflglong & 0x0f) != 0x0)//if 2
C51 COMPILER V7.08 OK 12/03/2006 10:17:14 PAGE 3
118 3 {
119 4 switch ((highkeyflglong & 0x0f))//highkeyflgshort
120 4 {
121 5 case 0x01: o5();//L_A
122 5 break;
123 5 case 0x02: o6();//L_B
124 5 break;
125 5 case 0x04: o7();//L_C
126 5 break;
127 5 case 0x08: o8();//L_D
128 5 break;
129 5
130 5 default: delayNms (30);//保证时基的均匀
131 5 break;
132 5 }//switch 2 end
133 4 highkeyflglong =highkeyflglong & 0xf0;//得到有效按键,只播放一次,故要清掉
134 4 }// if 2 end
135 3 else//未进入两个SWITCH
136 3 delayNms (60);//保证时基的均匀
137 3
138 3 }//if 1 else is end
139 2
140 2 } //for end
141 1
142 1
143 1 }//main end
144
145 /****************************************************************/
146 void readkey (void) //扫描时间较确定
147 {
148 1
149 1 /**************************in_key_A*******************************/
150 1 if (in_key_A) //如果A按下
151 1 { highkeycount_A++;} //时间累积
152 1 else
153 1 {
154 2 if(highkeycount_A>0)
155 2 {
156 3
157 3
158 3 if ( highkeycount_A > highlongtime )//长信号
159 3
160 3 { highkeyflglong_A = 1;
161 4 highkeyflgshort_A = 0;
162 4 }
163 3 else
164 3 { highkeyflgshort_A = 1;
165 4 highkeyflglong_A = 0;
166 4 }
167 3 // }
168 3 }
169 2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -