Mikroelektronika MIKROE-442 Datenbogen
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
639
FFT
Prototype
sub procedure FFT(dim log2N as word, dim TwiddleFactorsAddress as longint,
dim byref Samples as word[1024])
Description Function applies FFT transformation to input samples, input samples must be in Y data space.
-
f(n):
array of complex input samples
-
WN:
TwiddleFactors
-
N =
2m, mϵZ
The amplitude of current FFT sample is calculated as:
Parameters -
log2N:
buffer length (must be the power of 2).
- T
widdleFactorsAddress:
address of constant array which contains complex twiddle factors. The
array is expected to be in program memory. See Twiddle Factors for adequate array values.
-
Samples:
array of input samples. Upon completion, complex array of FFT samples is placed in the
Samples:
parameter.
Returns
Nothing.
Requires
Nothing.
Example
dim InputSamples as word[512] ydata
...
‘ Perform FFT (DFT), 7 stages, 128 samples of complex pairs
FFT(8, TwiddleCoeff_256, InputSamples)
Notes
Complex array of FFT samples is placed in Samples parameter. Input Samples are arranged in manner
Re,Im,Re,Im... (where Im is always zero). Output samples are arranged in the same manner but Im
parts are different from zero. Output samples are symmetrical (First half of output samples (index from
0 to N/2) is identical as second half of output samples(index from N/2 to N).
Input data is a complex vector such that the magnitude of the real and imaginary parts of each of its
elements is less than 0.5. If greater or equal to this value the results could produce saturation. Note
that the output values are scaled by a factor of 1/N, with N the length of the FFT. input is expected in
natural ordering, while output is produced in bit reverse ordering.
FFT Library
mikroBasic PRO for dsPIC30/33 and PIC24 includes a library for FFT calculation. All routines work with fractional Q15
format.
Library Dependency Tree
Library Routines
- FFT