This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C6678中dsplib中fft库函数计算结果与matlab不符

我在使用dsplib中的fft库函数时,我使用相同的数据(matlab产生,用single转换为单精度模式,写入dat文件中,在CCS端使用load memory加载到指定数组),使用TI参考的例程,但是计算得到的结果与matlab并不一致。下面是程序和部分数据的截图,FFT_Out是DSPfft库函数的计算输出。下面的截图展示的是部分数据,请问为什么会这样?

#include <stdint.h>
#include <math.h>
#include <stdio.h>                  // C 语言标准输入输出函数库
#include <math.h>                   // C 数学函数库
#include "mathlib.h"                // DSP 数学函数库
#include "dsplib.h"                 // DSP 函数库

/* Global definitions */
/* Number of samples for which FFT needs to be calculated */
#define N 16384
/* Number of unique sine waves in input data */
#define NUM_SIN_WAVES 4
#define SW_BREAKPOINT     asm(" SWBP 0 ");
#define PI                3.141592654
#define F_TOL             (1e-06)

#pragma DATA_ALIGN(Input, 8);// 信号
float Input[2*N];
float InputOrig[2*N];// 信号 副本
#pragma DATA_ALIGN(FFT_Out, 8);// FFT 输出
float FFT_Out[2*N];
#pragma DATA_ALIGN(IFFT_Out, 8);// IFFT 输出
float IFFT_Out[2*N];
#pragma DATA_ALIGN(W, 8);// 旋转因子
float W[2*N];
#pragma DATA_ALIGN(x, 8);// 旋转因子
float x[2*N];

/* Align the tables that we have to use */

unsigned char brev[64] = {
    0x0, 0x20, 0x10, 0x30, 0x8, 0x28, 0x18, 0x38,
    0x4, 0x24, 0x14, 0x34, 0xc, 0x2c, 0x1c, 0x3c,
    0x2, 0x22, 0x12, 0x32, 0xa, 0x2a, 0x1a, 0x3a,
    0x6, 0x26, 0x16, 0x36, 0xe, 0x2e, 0x1e, 0x3e,
    0x1, 0x21, 0x11, 0x31, 0x9, 0x29, 0x19, 0x39,
    0x5, 0x25, 0x15, 0x35, 0xd, 0x2d, 0x1d, 0x3d,
    0x3, 0x23, 0x13, 0x33, 0xb, 0x2b, 0x1b, 0x3b,
    0x7, 0x27, 0x17, 0x37, 0xf, 0x2f, 0x1f, 0x3f
};

void gen_twiddle_fft_sp (float *w, int n)
{
    int i, j, k;
//    const double PI = 3.141592654;

    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;
        }
    }
}

void main () {
    /* Generate the input data */
//    generateInput (NUM_SIN_WAVES);

    /* Genarate twiddle factors */
    gen_twiddle_fft_sp(W, N);
    SW_BREAKPOINT
    /* Call FFT routine */
    DSPF_sp_fftSPxSP(N, Input, W, FFT_Out, brev, 4, 0, N);
    SW_BREAKPOINT
}

CCS显示的部分计算结果

matlab的计算结果

使用的数据文件6683.ccsdata.dat