📄 int_fft.lst
字号:
200 5 {
201 6 SinVal = SinTable[sin_index];
202 6 CosVal = SinTable[(NUM_FFT/4) - sin_index];
203 6 }
204 5
205 5 // The SIN and COS values are used here to calculate part of the
206 5 // Butterfly equation
207 5 ReTwid.l = ((long)TempReB * CosVal) +
208 5 ((long)TempImB * SinVal);
209 5
210 5 ImTwid.l = ((long)TempImB * CosVal) -
211 5 ((long)TempReB * SinVal);
212 5
213 5 // Using the values calculated above, the new variables
214 5 // are computed
215 5
216 5 // Calculate new value for ReArray[indexA]
217 5 TempL.i[1] = 0;
218 5 TempL.i[0] = TempReA;
219 5 TempL.l = TempL.l >> 1;
220 5 ReTwid.l += TempL.l;
221 5 if ((ReTwid.l < 0)&&(ReTwid.i[1]))
222 5 TempReA2 = ReTwid.i[0] + 1;
223 5 else TempReA2 = ReTwid.i[0];
224 5 // Calculate new value for ReArray[indexB]
225 5 TempL.l = TempL.l << 1;
226 5 TempL.l -= ReTwid.l;
227 5 if ((TempL.l < 0)&&(TempL.i[1]))
228 5 TempReB2 = TempL.i[0] + 1;
229 5 else TempReB2 = TempL.i[0];
230 5
231 5 // Calculate new value for ImArray[indexA]
232 5 TempL.i[1] = 0;
233 5 TempL.i[0] = TempImA;
234 5 TempL.l = TempL.l >> 1;
235 5 ImTwid.l += TempL.l;
236 5 if ((ImTwid.l < 0)&&(ImTwid.i[1]))
237 5 TempImA = ImTwid.i[0] + 1;
238 5 else TempImA = ImTwid.i[0];
239 5
240 5 // Calculate new value for ImArray[indexB]
241 5 TempL.l = TempL.l << 1;
C51 COMPILER V8.02 INT_FFT 05/09/2008 21:51:23 PAGE 5
242 5 TempL.l -= ImTwid.l;
243 5 if ((TempL.l < 0)&&(TempL.i[1]))
244 5 TempImB = TempL.i[0] + 1;
245 5 else TempImB = TempL.i[0];
246 5
247 5 }
248 4
249 4 ReArray[indexA] = TempReA2;
250 4 ReArray[indexB] = TempReB2;
251 4 ImArray[indexA] = TempImA;
252 4 ImArray[indexB] = TempImB;
253 4
254 4 indexA++;
255 4 sin_index += group;
256 4 } // END of stage FOR loop (s_cnt)
257 3 indexA = indexB + 1;
258 3 sin_index = 0;
259 3 } // END of group FOR loop (g_cnt)
260 2
261 2 group /= 2;
262 2 stage *= 2;
263 2 } // END of While loop
264 1
265 1 } // END Int_FFT
266
267
268
269
270 //-----------------------------------------------------------------------------
271 // WindowCalc
272 //-----------------------------------------------------------------------------
273 //
274 // Uses the values in WindowFunc[] to window the stored data.
275 //
276 // The WindowFunc[] Array contains window coefficients between samples
277 // 0 and (NUM_FFT/2)-1, and samples from NUM_FFT/2 to NUM_FFT-1 are the mirror
278 // image of the other side.
279 // Window values are interpreted as a fraction of 1 (WindowFunc[x]/65536).
280 // The value at NUM_FFT/2 is assumed to be 1.0 (65536).
281 //
282 // If SE_data = 1, the input data is assumed to be single-ended, and is
283 // converted to a 2's complement, differential representation, to cancel the DC
284 // offset.
285 //
286 void WindowCalc(int Win_Array[], unsigned char SE_data)
287 {
288 1
289 1 #if (WINDOW_TYPE != 0) // Use this section if a window has been specified
290 1
291 1 IBALONG NewVal;
292 1
293 1 if (SE_data) // If data is single-ended,
294 1 Win_Array[0] ^= 0x8000; // convert it to differential
295 1 NewVal.l = (long)Win_Array[0] * WindowFunc[0];
296 1
297 1 if ((NewVal.l < 0)&&(NewVal.i[1]))
298 1 Win_Array[0] = NewVal.i[0] + 1;
299 1 else Win_Array[0] = NewVal.i[0];
300 1
301 1 if (SE_data) // If data is single-ended,
302 1 Win_Array[NUM_FFT/2] ^= 0x8000; // convert it to differential
303 1
C51 COMPILER V8.02 INT_FFT 05/09/2008 21:51:23 PAGE 6
304 1 for (index = 1; index < NUM_FFT/2; index++)
305 1 {
306 2 // Array positions 1 to (NUM_FFT/2 - 1)
307 2 if (SE_data) // If data is single-ended,
308 2 Win_Array[index] ^= 0x8000; // convert it to differential
309 2 NewVal.l = (long)Win_Array[index] * WindowFunc[index];
310 2 if ((NewVal.l < 0)&&(NewVal.i[1]))
311 2 Win_Array[index] = NewVal.i[0] + 1;
312 2
313 2 else Win_Array[index] = NewVal.i[0];
314 2
315 2 // Array positions (NUM_FFT/2 + 1) to (NUM_FFT - 1)
316 2 if (SE_data) // If data is single-ended,
317 2 Win_Array[NUM_FFT-index] ^= 0x8000; // convert it to differential
318 2 NewVal.l = (long)Win_Array[NUM_FFT-index] * WindowFunc[index];
319 2
320 2 if ((NewVal.l < 0)&&(NewVal.i[1]))
321 2 Win_Array[NUM_FFT-index] = NewVal.i[0] + 1;
322 2 else Win_Array[NUM_FFT-index] = NewVal.i[0];
323 2
324 2 }
325 1
326 1 #endif
327 1
328 1 #if (WINDOW_TYPE == 0) // Compile this if no window has been specified
if (SE_data) // If data is single-ended,
{ // convert it to differential
for (index = 0; index < NUM_FFT; index++)
{
Win_Array[index] ^= 0x8000; // XOR MSB with '1' to invert
}
}
#endif
340 1
341 1 } // END WindowCalc
342
343
344 //-----------------------------------------------------------------------------
345 // Bit_Reverse
346 //-----------------------------------------------------------------------------
347 //
348 // Sorts data in Bit Reversed Address order
349 //
350 // The BRTable[] array is used to find which values must be swapped. Only
351 // half of this array is stored, to save code space. The second half is
352 // assumed to be a mirror image of the first half.
353 //
354 void Bit_Reverse(int BR_Array[])
355 {
356 1
357 1 #if (NUM_FFT >= 512)
358 1 unsigned int swapA, swapB, sw_cnt; // Swap Indices
359 1 #endif
360 1
361 1 #if (NUM_FFT <= 256)
unsigned char swapA, swapB, sw_cnt; // Swap Indices
#endif
364 1
365 1 int TempStore;
C51 COMPILER V8.02 INT_FFT 05/09/2008 21:51:23 PAGE 7
366 1
367 1 // Loop through locations to swap
368 1 for (sw_cnt = 1; sw_cnt < NUM_FFT/2; sw_cnt++)
369 1 {
370 2 swapA = sw_cnt; // Store current location
371 2 swapB = BRTable[sw_cnt] * 2; // Retrieve bit-reversed index
372 2 if (swapB > swapA) // If the bit-reversed index is
373 2
374 2 { // larger than the current index,
375 3 TempStore = BR_Array[swapA]; // the two data locations are
376 3 BR_Array[swapA] = BR_Array[swapB]; // swapped. Using this comparison
377 3 BR_Array[swapB] = TempStore; // ensures that locations are only
378 3 } // swapped once, and never with
379 2 // themselves
380 2
381 2 swapA += NUM_FFT/2; // Now perform the same operations
382 2 swapB++; // on the second half of the data
383 2 if (swapB > swapA)
384 2 {
385 3 TempStore = BR_Array[swapA];
386 3 BR_Array[swapA] = BR_Array[swapB];
387 3 BR_Array[swapB] = TempStore;
388 3 }
389 2 }
390 1 }
*** WARNING C316 IN LINE 390 OF Int_FFT.c: unterminated conditionals
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 3055 ----
CONSTANT SIZE = 2560 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 6 80
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -