?? main.lst
字號:
C51 COMPILER V7.06 MAIN 01/08/2006 12:36:00 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: f:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /**********************************************
2 Main.C file
3 The AD9958's Main file
4 Creat by Computer-lov Date: 2005.8.30
5 Last edit date:2005.8.30
6 Copyright(C) 2005-2015 Computer-lov
7 All rights reserved
8 ************************************************/
9
10 #include <aduc841.h>
11 #include "ad9958.h"
12 #include "isr.h"
13 #include "serial_port.h"
14 #include "adc.h"
15
16 void delayXms(unsigned int x)
17 {
18 1 unsigned int j;
19 1 while(x--)
20 1 for(j=0;j<100;j++);
21 1 }
22
23 unsigned int current_voltage;
24 unsigned long int current_f;
25
26
27 void frequency(void)
28 {
29 1 unsigned long int f;
30 1 TR2=0;
31 1 f=100000*(receive_buffer[1]-'0')+10000*(receive_buffer[2]-'0')+1000*(receive_buffer[3]-'0')+100*(receive_
-buffer[5]-'0')+10*(receive_buffer[6]-'0')+receive_buffer[7]-'0';
32 1 if(receive_buffer[8]=='M')
33 1 {
34 2 f=f*1000;
35 2 }
36 1 current_f=f;
37 1
38 1 write_CSR(0x80); //CH1
39 1
40 1 //write_FR1(0x14,0x00,0x00);
41 1 // write_FR2(0x00,0x00);
42 1
43 1 write_CFR(0x00,0x03,0x00); //no modulation
44 1 write_CPW0(0x00);
45 1 write_ACR(0x1000 | current_voltage);
46 1 set_frequency(f);
47 1 write_CSR(0x70);
48 1 set_frequency(0);
49 1 run();
50 1 }
51
52
53
54 void voltage(void)
C51 COMPILER V7.06 MAIN 01/08/2006 12:36:00 PAGE 2
55 {
56 1 TR2=0;
57 1 switch(receive_buffer[1])
58 1 {
59 2 case 0: current_voltage+=1;
60 2 if(current_voltage>1000)current_voltage=1000;
61 2 break;
62 2 case 1: current_voltage+=10;
63 2 if(current_voltage>1000)current_voltage=1000;
64 2 break;
65 2 case 2: current_voltage+=100;
66 2 if(current_voltage>1000)current_voltage=1000;
67 2 break;
68 2 case 3: current_voltage-=1;
69 2 if(current_voltage>1000)current_voltage=0;
70 2 break;
71 2 case 4: current_voltage-=10;
72 2 if(current_voltage>1000)current_voltage=0;
73 2 break;
74 2 case 5: current_voltage-=100;
75 2 if(current_voltage>1000)current_voltage=0;
76 2 break;
77 2 default: break;
78 2 }
79 1 write_CSR(0x80);
80 1 write_CFR(0x00,0x03,0x00); //no modulation
81 1 write_ACR(0x1000 | current_voltage);
82 1 run();
83 1 }
84
85 unsigned char code_sequence;
86
87 void PSK(void)
88 {
89 1 code_sequence=100*(receive_buffer[1]-'0')+10*(receive_buffer[2]-'0')+receive_buffer[3]-'0';
90 1
91 1 T2CON=0x00; //定時器自動重裝模式
92 1 RCAP2H=0xF8;
93 1 RCAP2L=0x30; //定時時間為100uS
94 1
95 1 write_CSR(0x80);
96 1 write_CFR(0xC0,03,0x00);
97 1 write_CPW0(0x00);
98 1 write_CTWn(1,0x80000000);
99 1 set_frequency(100000);
100 1 run();
101 1 printc(0xEF);
102 1 ET2=1;
103 1 TR2=1;
104 1 }
105
106
107 void ASK(void)
108 {
109 1 code_sequence=100*(receive_buffer[1]-'0')+10*(receive_buffer[2]-'0')+receive_buffer[3]-'0';
110 1 T2CON=0x00; //定時器自動重裝模式
111 1 RCAP2H=0xF8;
112 1 RCAP2L=0x30; //定時時間為100uS
113 1
114 1 write_CSR(0x80);
115 1 write_CFR(0x40,03,0x00);
116 1 write_CPW0(0x00);
C51 COMPILER V7.06 MAIN 01/08/2006 12:36:00 PAGE 3
117 1 write_CTWn(1,0x00);
118 1 set_frequency(100000);
119 1 run();
120 1 printc(0xEF);
121 1 ET2=1;
122 1 TR2=1;
123 1 }
124
125 void AM(void)
126 {
127 1 unsigned char temp;
128 1 unsigned int s_voltage;
129 1 temp=receive_buffer[1];
130 1 switch(temp)
131 1 {
132 2 case 1: s_voltage=94; break;
133 2 case 2: s_voltage=189;break;
134 2 case 3: s_voltage=283;break;
135 2 case 4: s_voltage=377;break;
136 2 case 5: s_voltage=472;break;
137 2 case 6: s_voltage=566;break;
138 2 case 7: s_voltage=660;break;
139 2 case 8: s_voltage=754;break;
140 2 case 9: s_voltage=849;break;
141 2 case 10: s_voltage=943;break;
142 2 default :break;
143 2 }
144 1 write_CSR(0x80);
145 1 write_ACR(0x0010ff);
146 1
147 1 write_CSR(0x70);
148 1 write_ACR(0x1000 | s_voltage);
149 1 set_frequency(1000);
150 1 run();
151 1 }
152
153 #define SDIO_3 P2_7
154 #define SDIO_2 P2_6
155 #define SDIO_1 P2_5
156 #define SDIO_0 P2_4
157 #define SCLK P0_1
158 #define CS P0_2
159
160
161
162 void out_f(signed long int delta_f)
163 {
164 1 unsigned long int temp;
165 1 unsigned char x1,x2,x3,x4;
166 1 ////////////////////////////////////////////
167 1 P2=0x00;
168 1 SCLK=1;
169 1 SCLK=0;
170 1 P2=0x40;
171 1 SCLK=1;
172 1 SCLK=0;
173 1
174 1
175 1 temp=delta_f+current_f;
176 1
177 1 x1 =((unsigned char *)&temp)[0];
178 1 x2 =((unsigned char *)&temp)[1];
C51 COMPILER V7.06 MAIN 01/08/2006 12:36:00 PAGE 4
179 1 x3 =((unsigned char *)&temp)[2];
180 1 x4 =((unsigned char *)&temp)[3];
181 1
182 1
183 1 P2=x1;
184 1 x1<<=4;
185 1 SCLK=1;
186 1 SCLK=0;
187 1 P2=x1;
188 1 SCLK=1;
189 1 SCLK=0;
190 1
191 1 P2=x2;
192 1 x2<<=4;
193 1 SCLK=1;
194 1 SCLK=0;
195 1 P2=x2;
196 1 SCLK=1;
197 1 SCLK=0;
198 1
199 1 P2=x3;
200 1 x3<<=4;
201 1 SCLK=1;
202 1 SCLK=0;
203 1 P2=x3;
204 1 SCLK=1;
205 1 SCLK=0;
206 1
207 1 P2=x4;
208 1 x4<<=4;
209 1 SCLK=1;
210 1 SCLK=0;
211 1 P2=x4;
212 1 SCLK=1;
213 1 SCLK=0;
214 1
215 1 run();
216 1 ////////////////////////////////
217 1 }
218
219 void FM5K(void)
220 {
221 1 write_CSR(0x86);
222 1 run();
223 1 CS=0;
224 1 while(1)
225 1 {
226 2 out_f( 0 );
227 2 out_f( 9528 );
228 2 out_f( 19033 );
229 2 out_f( 28492 );
230 2 out_f( 37883 );
231 2 out_f( 47182 );
232 2 out_f( 56368 );
233 2 out_f( 65418 );
234 2 out_f( 74310 );
235 2 out_f( 83023 );
236 2 out_f( 91536 );
237 2 out_f( 99829 );
238 2 out_f( 107881 );
239 2 out_f( 115673 );
240 2 out_f( 123187 );
C51 COMPILER V7.06 MAIN 01/08/2006 12:36:00 PAGE 5
241 2 out_f( 130404 );
242 2 out_f( 137307 );
243 2 out_f( 143878 );
244 2 out_f( 150104 );
245 2 out_f( 155967 );
246 2 out_f( 161455 );
247 2 out_f( 166554 );
248 2 out_f( 171252 );
249 2 out_f( 175537 );
250 2 out_f( 179400 );
251 2 out_f( 182830 );
252 2 out_f( 185819 );
253 2 out_f( 188361 );
254 2 out_f( 190450 );
255 2 out_f( 192079 );
256 2 out_f( 193246 );
257 2 out_f( 193947 );
258 2 out_f( 194181 );
259 2 out_f( 193947 );
260 2 out_f( 193246 );
261 2 out_f( 192079 );
262 2 out_f( 190450 );
263 2 out_f( 188361 );
264 2 out_f( 185819 );
265 2 out_f( 182830 );
266 2 out_f( 179400 );
267 2 out_f( 175537 );
268 2 out_f( 171252 );
269 2 out_f( 166554 );
270 2 out_f( 161455 );
271 2 out_f( 155967 );
272 2 out_f( 150104 );
273 2 out_f( 143878 );
274 2 out_f( 137307 );
275 2 out_f( 130404 );
276 2 out_f( 123187 );
277 2 out_f( 115673 );
278 2 out_f( 107881 );
279 2 out_f( 99829 );
280 2 out_f( 91536 );
281 2 out_f( 83023 );
282 2 out_f( 74310 );
283 2 out_f( 65418 );
284 2 out_f( 56368 );
285 2 out_f( 47182 );
286 2 out_f( 37883 );
287 2 out_f( 28492 );
288 2 out_f( 19033 );
289 2 out_f( 9528 );
290 2 out_f( 0 );
291 2 out_f( -9528 );
292 2 out_f( -19033 );
293 2 out_f( -28492 );
294 2 out_f( -37883 );
295 2 out_f( -47182 );
296 2 out_f( -56368 );
297 2 out_f( -65418 );
298 2 out_f( -74310 );
299 2 out_f( -83023 );
300 2 out_f( -91536 );
301 2 out_f( -99829 );
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -