Functions for performing forward and inverse FFT of complex 16-bit and 32-bit input data.
Complex forward FFT function with auto-scaling.
- Details
- Computes the forward discreet Fourier transform (DFT) of 16-bit complex inputs. If the inputs are not already in bit reversed order the bit reversal parameter must be set. The output is monitored for overflow and scaled by a factor of two when an overflow risk is detected. The shift parameter contains the number of bit shifts that were applied to the output.
- Pseudo code
y = fft(x) * 2^-shift
- Scaling
- Scaling is applied as needed to prevent saturation of the output. The scale factor that was applied to the output is returned in the shift parameter and can be used to calculate the result by applying the following function.
result = result * 2^shift
- LEA Support
- This function is supported by LEA and requires data to be placed into shared LEA memory with alignment equal to four times the data length (e.g. a 256-point complex FFT requires 1024-byte alignment). When allocating data the MSP_CMPLX_ALIGN_FFT_Q15 macro can be used to calculate correct alignment. The twiddle table pointer parameter is not used with LEA and can be null or uninitialized.
- Parameters
-
params | Pointer to the complex FFT parameter structure. |
src | Pointer to the complex data array to perform the FFT on. |
shift | Auto-scaling shift that was applied to the output. |
- Returns
- Status of the operation.
- Examples:
- transform_ex2_cmplx_fft_auto_q15.c.
Complex forward FFT function with fixed scaling by two at each stage.
- Details
- Computes the forward discreet Fourier transform (DFT) of 16-bit complex inputs. If the inputs are not already in bit reversed order the bit reversal parameter must be set. The output is scaled by a factor of two for each stage of the DFT.
- Pseudo code
y = fft(x) ./ N
- Scaling
- Each stage of the complex FFT scales the result by a factor of 0.5. The output format can either be interpreted as the same type with (1/N) scaling or a different fixed point data type. This can be helpful when using the IQmathLib to process the results of the FFT, such as computing the magnitude or phase angle of the complex result.
-
Length | Input Type | Result Type |
16 | _q15 | _q11 |
32 | _q15 | _q10 |
64 | _q15 | _q9 |
128 | _q15 | _q8 |
256 | _q15 | _q7 |
512 | _q15 | _q6 |
1024 | _q15 | _q5 |
2048 | _q15 | _q4 |
4096 | _q15 | _q3 |
- The following table lists the applied scaling factor and resulting data type when the input is a 16-bit integer.
-
Length | Input Type | Result Type |
16 | int16_t | (int16_t)(result / 16) |
32 | int16_t | (int16_t)(result / 32) |
64 | int16_t | (int16_t)(result / 64) |
128 | int16_t | (int16_t)(result / 128) |
256 | int16_t | (int16_t)(result / 256) |
512 | int16_t | (int16_t)(result / 512) |
1024 | int16_t | (int16_t)(result / 1024) |
2048 | int16_t | (int16_t)(result / 2048) |
4096 | int16_t | (int16_t)(result / 4096) |
- LEA Support
- This function is supported by LEA and requires data to be placed into shared LEA memory with alignment equal to four times the data length (e.g. a 256-point complex FFT requires 1024-byte alignment). When allocating data the MSP_CMPLX_ALIGN_FFT_Q15 macro can be used to calculate correct alignment. The twiddle table pointer parameter is not used with LEA and can be null or uninitialized.
- Parameters
-
params | Pointer to the complex FFT parameter structure. |
src | Pointer to the complex data array to perform the FFT on. |
- Returns
- Status of the operation.
Complex forward FFT function without scaling.
- Details
- Computes the forward discreet Fourier transform (DFT) of 32-bit complex inputs. If the inputs are not already in bit reversed order the bit reversal parameter must be set. The output is not scaled.
- Pseudo code
y = fft(x)
- LEA Support
- This function is supported by LEA and requires data to be placed into shared LEA memory with alignment equal to eight times the data length (e.g. a 256-point complex FFT requires 2048-byte alignment). When allocating data the MSP_CMPLX_ALIGN_FFT_IQ31 macro can be used to calculate correct alignment. The twiddle table pointer parameter is not used with LEA and can be null or uninitialized.
- Parameters
-
params | Pointer to the complex FFT parameter structure. |
src | Pointer to the complex data array to perform the FFT on. |
- Returns
- Status of the operation.
Complex inverse FFT function with auto-scaling.
- Details
- Computes the inverse discreet Fourier transform (DFT) of 16-bit complex inputs. If the inputs are not already in bit reversed order the bit reversal parameter must be set. The output is monitored for overflow and scaled by a factor of two when an overflow risk is detected. Automatic scaling is performed such that this is the direct inverse of the forward FFT with auto scaling.
- Pseudo code
y = (ifft(x) * 2^shift) ./ N
- LEA Support
- This function is supported by LEA and requires data to be placed into shared LEA memory with alignment equal to four times the data length (e.g. a 256-point complex FFT requires 1024-byte alignment). When allocating data the MSP_CMPLX_ALIGN_FFT_Q15 macro can be used to calculate correct alignment. The twiddle table pointer parameter is not used with LEA and can be null or uninitialized.
- Parameters
-
params | Pointer to the complex FFT parameter structure. |
src | Pointer to the complex data array to perform the FFT on. |
shift | Auto-scaling shift that was applied to the output. |
- Returns
- Status of the operation.
Complex inverse FFT function with fixed scaling by two at each stage.
- Details
- Computes the inverse discreet Fourier transform (DFT) of 16-bit complex inputs. If the inputs are not already in bit reversed order the bit reversal parameter must be set. Fixed scaling is performed such that this is the direct inverse of the forward FFT with fixed scaling.
- Pseudo code
y = ifft(x)
- Scaling
- This function is the direct inverse of the forward complex FFT with fixed scaling. The following fixed point input types will all result in Q15 results.
-
Length | Input Type | Result Type |
16 | _q11 | _q15 |
32 | _q10 | _q15 |
64 | _q9 | _q15 |
128 | _q8 | _q15 |
256 | _q7 | _q15 |
512 | _q6 | _q15 |
1024 | _q5 | _q15 |
2048 | _q4 | _q15 |
4096 | _q3 | _q15 |
- LEA Support
- This function is supported by LEA and requires data to be placed into shared LEA memory with alignment equal to four times the data length (e.g. a 256-point complex FFT requires 1024-byte alignment). When allocating data the MSP_CMPLX_ALIGN_FFT_Q15 macro can be used to calculate correct alignment. The twiddle table pointer parameter is not used with LEA and can be null or uninitialized.
- Parameters
-
params | Pointer to the complex FFT parameter structure. |
src | Pointer to the complex data array to perform the FFT on. |
- Returns
- Status of the operation.
Complex inverse FFT function without scaling.
- Details
- Computes the inverse discreet Fourier transform (DFT) of 32-bit complex inputs. If the inputs are not already in bit reversed order the bit reversal parameter must be set. Fixed scaling is performed such that this is the direct inverse of the forward FFT without scaling.
- Pseudo code
y = ifft(x) ./ N
- LEA Support
- This function is supported by LEA and requires data to be placed into shared LEA memory with alignment equal to eight times the data length (e.g. a 256-point complex FFT requires 2048-byte alignment). When allocating data the MSP_CMPLX_ALIGN_FFT_IQ31 macro can be used to calculate correct alignment. The twiddle table pointer parameter is not used with LEA and can be null or uninitialized.
- Parameters
-
params | Pointer to the complex FFT parameter structure. |
src | Pointer to the complex data array to perform the FFT on. |
- Returns
- Status of the operation.