📄 test.lst
字号:
C51 COMPILER V7.06 TEST 12/19/2006 15:55:33 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE TEST
OBJECT MODULE PLACED IN .\test.obj
COMPILER INVOKED BY: D:\Program Files\Keil\C51\BIN\C51.EXE ..\..\..\..\..\cprogram\laptopUV\基础子程序\motor\test.c BROW
-SE FLOATFUZZY(2) DEBUG OBJECTEXTEND PRINT(.\test.lst) OBJECT(.\test.obj)
stmt level source
1 #include <reg52.h>
2 #include <intrins.h>
3 #include <math.h>
4 #include <absacc.h>
5
6
7
8 #define ADDR_DATA_WR 0xA000
9 #define ADDR_DATA_RD 0xA002
10 #define ADDR_INS_WR 0xA001
11 #define ADDR_STATUS_RD 0xA003
12 #define INS_8279 0x8001
13 #define DATA_8279 0x8000
14 #define ADDR_0832_W 0XF600
15 #define ADDR_0832_R 0XF800
16 #define ADDR_CHANNEL_SEL 0XF000
17 #define LIGHT_PULSE_UP LIGHT=1
18 #define LIGHT_PULSE_DOWN LIGHT=0
19 #define AD_START XBYTE[0XA000]
20 #define AD_H8 XBYTE[0XA000]
21 #define AD_L4 XBYTE[0XA001]
22 #define ADDR_CLOCK 0X9000
23 #define ADDR_INT XBYTE[0xf400]
24 #define STEP_OFFSET 1648
25 #define GAIN_W_L8 XBYTE[0XB000]
26 #define GAIN_W_H4 XBYTE[0XB001]
27 #define GAIN_R_L8 XBYTE[0XB002]
28 #define GAIN_R_H4 XBYTE[0XB003]
29 #define GAIN_UPDATE XBYTE[0XC000]
30 #define MOTOR_0 0X01
31 #define MOTOR_1 0X00
32 #define MOTOR_PULSE_UP PULSE=1
33 #define MOTOR_PULSE_DOWN PULSE=0
34 #define ZERO_OFFSET 2000
35 #define DIR_FORWARD 0X01
36 #define DIR_BACKWARD 0X00
37 #define SUCCESS 0X01
38 #define STEP_COUNT_WHITE 0X00
39 #define STEP_COUNT_ORANGE 1025
40 #define STEP_COUNT_BLANK 3075
41 #define FILTER_BLANK 0X00
42 #define FILTER_WHITE 0X01
43 #define FILTER_ORANGE 0X02
44
45
46 char func1(char i);
47 char func2(char i);
48 void EnableTimer0(unsigned char Enable ) ;
49 void Delay ( unsigned int Step );
50
51 sbit DIR=P1^5;
52 sbit PULSE=P1^6;
53 sbit LIGHT=P1^7;
54 sbit ADDR_MOTOR = P1^2;
C51 COMPILER V7.06 TEST 12/19/2006 15:55:33 PAGE 2
55 unsigned char bdata REG_BIT;
56 float G_MOTOR_PARA[3] ;
57 unsigned int G_StepOffset ;
58 unsigned int MaxSampleValue ;
59 unsigned int Count ;
60 unsigned int G_FilterPos ;
61
62
63 int Sample0( )
64 {
65 1 unsigned char xdata IntNum ;
66 1 unsigned int xdata Cycle ;
67 1 unsigned int xdata DataW ;
68 1
69 1 unsigned int xdata DataWSum ;
70 1
71 1
72 1
73 1 DataWSum = 0 ;
74 1 for ( Cycle = 0 ; Cycle < 30 ; Cycle++ )
75 1 {
76 2 IntNum |= 0X80 ;
77 2 AD_START = 0x10 ; //启动转换
78 2 while( IntNum & 0X80 ) //工作通道转换结束,K开始接受数据
79 2 {
80 3 IntNum = ADDR_INT ;
81 3 }
82 2 Delay (10) ;
83 2 DataW = AD_H8 ;
84 2 DataW = _irol_ ( DataW , 4 );
85 2 DataW += AD_L4 /16 ;
86 2 DataWSum += DataW / 30 ;
87 2 }
88 1 return DataWSum ;
89 1
90 1 }
91 void SelectFilter ( unsigned char SelectNum )
92 {
93 1 unsigned char IntNum ;
94 1 unsigned int cycle ;
95 1 unsigned int Step ;
96 1 unsigned int StepCount ;
97 1
98 1
99 1 ADDR_MOTOR = MOTOR_1 ;
100 1 DIR=DIR_FORWARD;
101 1 IntNum = ADDR_INT ;
102 1 ;
103 1 while((IntNum&0x10 ))
104 1 {
105 2 PULSE=!PULSE;
106 2 for (cycle=0;cycle<300;cycle++){}
107 2 PULSE=!PULSE; /*there is integrity more than interest*/
108 2
109 2 /* for(cycle=0;cycle<100;cycle++){}*/ /*the frequency has been doubled WHY*/
110 2
111 2
112 2 for(cycle=0;cycle<200;cycle++){} /*KEIL code efficiency is better than franklin*/
113 2 IntNum = ADDR_INT ;
114 2
115 2
116 2 }
C51 COMPILER V7.06 TEST 12/19/2006 15:55:33 PAGE 3
117 1 DIR = DIR_BACKWARD ;
118 1 for ( Step = 0 ; Step < 300 ; Step ++ )
119 1 {
120 2 PULSE=!PULSE;
121 2 for (cycle=0;cycle<300;cycle++){}
122 2 PULSE=!PULSE;
123 2 for(cycle=0;cycle<200;cycle++){}
124 2 }
125 1
126 1
127 1 DIR=DIR_FORWARD;
128 1 IntNum = ADDR_INT ;
129 1 while((IntNum&0x10 ))
130 1 {
131 2 PULSE=!PULSE;
132 2 for (cycle=0;cycle<800;cycle++){}
133 2 PULSE=!PULSE;
134 2 for(cycle=0;cycle<400;cycle++){}
135 2 IntNum = ADDR_INT ;
136 2
137 2
138 2 }
139 1
140 1 switch ( SelectNum )
141 1 {
142 2 case FILTER_BLANK:
143 2 {
144 3 StepCount = STEP_COUNT_BLANK ;
145 3 break ;
146 3 }
147 2 case FILTER_WHITE:
148 2 {
149 3 StepCount = STEP_COUNT_WHITE ;
150 3 break ;
151 3 }
152 2 case FILTER_ORANGE:
153 2 {
154 3 StepCount = STEP_COUNT_ORANGE ;
155 3 break ;
156 3 }
157 2 }
158 1
159 1 for ( Step = 0 ; Step < StepCount ; Step ++ )
160 1 {
161 2 PULSE=!PULSE;
162 2 for (cycle=0;cycle<800;cycle++){}
163 2 PULSE=!PULSE;
164 2 for(cycle=0;cycle<400;cycle++){}
165 2 }
166 1
167 1 ADDR_MOTOR = MOTOR_0 ;
168 1
169 1 }
170
171 void IntTimer(void ) interrupt 1
172 {
173 1 unsigned int NewSampleValue ;
174 1
175 1 TR0=0;
176 1 TF0 = 0 ;
177 1 TH0 = 0X00;
178 1 TL0 = 0X00;
C51 COMPILER V7.06 TEST 12/19/2006 15:55:33 PAGE 4
179 1 TR0 = 1 ;
180 1 LIGHT_PULSE_UP ;
181 1 Delay (5) ;
182 1 LIGHT_PULSE_DOWN ;
183 1 Delay (6) ;
184 1 NewSampleValue = Sample0();
185 1
186 1 if ( NewSampleValue > MaxSampleValue )
187 1 {
188 2 Count ++ ;
189 2 MaxSampleValue = NewSampleValue ;
190 2 }
191 1 else
192 1 {
193 2 // EnableTimer0( 0X00 );
194 2 }
195 1
196 1 }
197
198 void Delay ( unsigned int Step )
199 {
200 1 unsigned int xdata Cycle ;
201 1
202 1 for ( Cycle = 0 ; Cycle < Step ; Cycle ++ )
203 1 {}
204 1 }
205
206 char Go2Zero( void )
207 {
208 1 unsigned char IntNum ;
209 1 unsigned int cycle ;
210 1 unsigned int Step ;
211 1
212 1 ADDR_MOTOR = MOTOR_0 ;
213 1 DIR=DIR_BACKWARD;
214 1 IntNum = ADDR_INT ;
215 1 IntNum &= 0x08 ;
216 1 while(!IntNum)
217 1 {
218 2 PULSE=!PULSE;
219 2 for (cycle=0;cycle<40;cycle++){}
220 2 PULSE=!PULSE; /*there is integrity more than interest*/
221 2
222 2 /* for(cycle=0;cycle<100;cycle++){}*/ /*the frequency has been doubled WHY*/
223 2
224 2
225 2 for(cycle=0;cycle<300;cycle++){} /*KEIL code efficiency is better than franklin*/
226 2 IntNum = ADDR_INT ;
227 2 IntNum &= 0x08 ;
228 2
229 2 }
230 1 DIR=DIR_FORWARD;
231 1 for ( Step = 0 ; Step < 500 ; Step ++ )
232 1 {
233 2 PULSE=!PULSE;
234 2 for (cycle=0;cycle<150;cycle++){}
235 2 PULSE=!PULSE;
236 2 for(cycle=0;cycle<600;cycle++){}
237 2 }
238 1 DIR = DIR_BACKWARD ;
239 1 IntNum = ADDR_INT ;
240 1 IntNum &= 0x08 ;
C51 COMPILER V7.06 TEST 12/19/2006 15:55:33 PAGE 5
241 1 while(!IntNum)
242 1 {
243 2 PULSE=!PULSE;
244 2 for (cycle=0;cycle<150;cycle++){}
245 2 PULSE=!PULSE; /*there is integrity more than interest*/
246 2
247 2 /* for(cycle=0;cycle<100;cycle++){}*/ /*the frequency has been doubled WHY*/
248 2
249 2
250 2 for(cycle=0;cycle<600;cycle++){} /*KEIL code efficiency is better than franklin*/
251 2 IntNum = ADDR_INT ;
252 2 IntNum &= 0x08 ;
253 2
254 2 }
255 1 DIR = DIR_FORWARD ;
256 1 for ( Step = 0 ; Step < G_StepOffset ; Step ++ )
257 1 {
258 2 PULSE=!PULSE;
259 2 for (cycle=0;cycle<150;cycle++){}
260 2 PULSE=!PULSE;
261 2 for(cycle=0;cycle<600;cycle++){}
262 2 }
263 1 Delay(8000);
264 1 return SUCCESS ;
265 1 }
266 char Go2Lumda ( unsigned int Lumda )
267 {
268 1 unsigned int Step ;
269 1 unsigned int cycle ;
270 1 unsigned int NewFilterPos ;
271 1 unsigned int WLPos ;
272 1
273 1 WLPos = Lumda ;
274 1 ADDR_MOTOR = MOTOR_0 ;
275 1 DIR = DIR_FORWARD ; //校准波长
276 1 Lumda = G_MOTOR_PARA[2] * Lumda * Lumda + G_MOTOR_PARA[ 1 ] * Lumda + G_MOTOR_PARA[ 0 ] ;
277 1 MOTOR_PULSE_DOWN ;
278 1 if ( Lumda < 3000 ) return ; //more than 150nm
*** WARNING C173 IN LINE 278 OF ..\..\..\..\..\CPROGRAM\LAPTOPUV\基础子程序\MOTOR\TEST.C: missing return-expression
279 1 for ( Step = 0 ; Step < 40 ; Step ++ )
280 1 {
281 2 PULSE=!PULSE;
282 2 for (cycle=0;cycle< (200 ) ;cycle++){}
283 2 PULSE=!PULSE;
284 2 for(cycle=0;cycle<(1000 );cycle++){}
285 2 }
286 1 for ( ; Step < 70 ; Step ++ )
287 1 {
288 2 PULSE=!PULSE;
289 2 for (cycle=0;cycle< (300 ) ;cycle++){}
290 2 PULSE=!PULSE;
291 2 for(cycle=0;cycle<(800 );cycle++){}
292 2 }
293 1 for ( ; Step < 90 ; Step ++ )
294 1 {
295 2 PULSE=!PULSE;
296 2 for (cycle=0;cycle<(200 ) ;cycle++){}
297 2 PULSE=!PULSE;
298 2 for(cycle=0;cycle<(600 );cycle++){}
299 2 }
300 1 for ( ; Step < 100 ; Step ++ )
301 1 {
C51 COMPILER V7.06 TEST 12/19/2006 15:55:33 PAGE 6
302 2 PULSE=!PULSE;
303 2 for (cycle=0;cycle<150;cycle++){}
304 2 PULSE=!PULSE;
305 2 for (cycle=0;cycle<400;cycle++){}
306 2 }
307 1 for ( ; Step < Lumda ; Step ++ )
308 1 {
309 2 PULSE=!PULSE;
310 2 for (cycle=0;cycle<100;cycle++){}
311 2 PULSE=!PULSE;
312 2 for (cycle=0;cycle<300;cycle++){}
313 2 }
314 1
315 1 if ( WLPos < 3200 )
316 1 {
317 2 NewFilterPos = FILTER_BLANK ;
318 2 }
319 1 else
320 1 {
321 2 if (WLPos > 6000 )
322 2 {
323 3 NewFilterPos = FILTER_ORANGE ;
324 3 }
325 2 else
326 2 {
327 3 NewFilterPos = FILTER_WHITE ;
328 3 }
329 2
330 2 }
331 1 if ( NewFilterPos != G_FilterPos )
332 1 {
333 2 G_FilterPos = NewFilterPos ;
334 2 SelectFilter ( NewFilterPos );
335 2 }
336 1 return SUCCESS ;
337 1 }
338
339 /*
340 char Adjust0832(void)
341 {
342 unsigned char data res_high;
343 unsigned char data res_low;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -