首先明确一点,C6678中FFT的函数形式为:
N : length of FFT in complex samples ptr_x : pointer to complex data
input ptr_w : pointer to complex twiddle factor ptr_y : pointer to
complex output data brev : pointer to bit reverse table containing 64
entries n_min : should be 4 if N can be represented as Power of 4
else, n_min should be 2 offset : index in complex samples of sub-fft
from start of main fft n_max : size of main fft in complex
samples(可令n_max=N)其中,64位bit反位表brev为: unsigned char brev[64] = { 0x00, 0x20, 0x10, 0x30,
0x08, 0x28, 0x18, 0x38, 0x04, 0x24, 0x14, 0x34, 0x0c, 0x2c, 0x1c,
0x3c, 0x02, 0x22, 0x12, 0x32, 0x0a, 0x2a, 0x1a, 0x3a, 0x06, 0x26,
0x16, 0x36, 0x0e, 0x2e, 0x1e, 0x3e, 0x01, 0x21, 0x11, 0x31, 0x09,
0x29, 0x19, 0x39, 0x05, 0x25, 0x15, 0x35, 0x0d, 0x2d, 0x1d, 0x3d,
0x03, 0x23, 0x13, 0x33, 0x0b, 0x2b, 0x1b, 0x3b, 0x07, 0x27, 0x17,
0x37, 0x0f, 0x2f, 0x1f, 0x3f };旋转矩阵(旋转因子)ptr_w为: void tw_fft_gen (float *w, int n) { int i, j, k; for
(j = 1, k = 0; j <= n >> 2; j = j << 2) { for (i = 0; i < n >> 2; i +=
j) {
#ifdef _LITTLE_ENDIAN w[k] = (float) sin (2 * PI * i / n); w[k + 1] = (float) cos (2 * PI * i / n); w[k + 2] = (float) sin (4 * PI * i / n);
w[k + 3] = (float) cos (4 * PI * i / n); w[k + 4] = (float) sin (6 *
PI * i / n); w[k + 5] = (float) cos (6 * PI * i / n);
#else w[k] = (float) cos (2 * PI * i / n); w[k + 1] = (float) -sin (2 * PI * i / n); w[k + 2] = (float) cos (4 * PI * i / n); w[k + 3] = (float) -sin (4 * PI * i / n); w[k + 4] = (float) cos (6 * PI * i /
n); w[k + 5] = (float) -sin (6 * PI * i / n);
#endif k += 6; } } }DSPF_sp_fftSPxSP函数的调用方式为:
1.下载库将下载好的库“dsplib_c66x_3_1_0_0”复制到CCS的安装路径下
2.添加头文件路径 右键点击工程–>Properties–>Build–>c6000 Compiler–>Include Options
3.添加库文件和库文件路径 右键点击工程–>Properties–>Build–>C6000 Linker–>File Search Path添加库文件和库文件路径
完成以上的准备工作后便可进行DSPF_sp_fftSPxSP函数的调用了。
在DSPC6657上的实际测试程序
#include <stdio.h>
#include <stdlib.h>
#include <c6x.h>
#include <math.h>
#include <dsplib.h>
#define FFT_NUM 1024 //单次FFT变换数据个数
#define Double_FFT_NUM FFT_NUM * 2 //单次FFT变换数据个数的两倍
#define PI 3.141592654 //圆周率
float sin_data[1024] =
{
1.000, 0.951, 0.809, 0.588, 0.309, 0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, -0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000,
-0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, 0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809,
0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309,
0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309,
-0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809,
1.000, 0.951, 0.809, 0.588, 0.309, 0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, 0.000, -0.309, -0.588, -0.809, -0.951, -1.000,
-0.809, -0.588, -0.309, 0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809, 0.588, 0.309, -0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, -0.000, 0.309, 0.588, 0.809, 0.951, 1.000, 0.951, 0.809,
0.309, 0.000, -0.309, -0.588, -0.809, -0.951, -1.000, -0.951, -0.809, -0.588, -0.309, 0.000, 0.309, 0.588