TI中文支持网
TI专业的中文技术问题搜集分享网站

关于DSPLIB中DSPF_sp_fftSPxSP_opt()、DSPF_sp_ifftSPxSP_opt()函数的使用问题

根据输入数据,DSPF_sp_fftSPxSP_opt()处理结果与Matlab相同,DSPF_sp_ifftSPxSP_opt()处理结果与Matlab不同,不知道IFFT所需要的参数设置是否与FFT不同,代码如下,希望问题得到解决,谢谢!

#include <stdint.h>
#include <math.h>
#include <stdio.h>

#include "DSPF_sp_ifftSPxSP.h"
#include "DSPF_sp_fftSPxSP.h"

#include "DSPF_sp_ifftSPxSP_opt.h"
#include "DSPF_sp_fftSPxSP_opt.h"

#include "DSPF_sp_ifftSPxSP_cn.h"
#include "DSPF_sp_fftSPxSP_cn.h"

#include "KeyStone_common.h"

int N = 256;
float w[512];
float Tr1_echo[512]={0};
float Tr1_result[512]={0};
float Tr1_result_real[256]={0};
float Tr1_result_imag[256]={0};
float Tr1_result_abs[256]={0};

//Turning complex into real and imaginary parts
seperateRealImg ()
{
int i, j;

for (i = 0, j = 0; j < N; i+=2, j++)
{
Tr1_result_real[j] = Tr1_result[i];
Tr1_result_imag[j] = Tr1_result[i + 1];
}
}

//Complex module
void abs2()
{
int i;
for (i = 0; i < N; i++)
{
Tr1_result_abs[i] = sqrt(Tr1_result_real[i]*Tr1_result_real[i]+Tr1_result_imag[i]*Tr1_result_imag[i]);
}
}

//read data from input.dat
void read_data_from_FILE()
{
int i;
FILE * fpRead=fopen("input.dat","r");
for( i=0;i<512;i++)
{
fscanf(fpRead,"%f",&Tr1_echo[i]);
printf("%f",Tr1_echo[i]);
}
fclose(fpRead);
}

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

/* Function for generating Specialized sequence of twiddle factors */
void tw_gen (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()
{
read_data_from_FILE();
tw_gen(w, 256);
DSPF_sp_ifftSPxSP_opt(N, Tr1_echo, w, Tr1_result, brev, 4, 0, N);
seperateRealImg();
abs2();
}

Shine:

DSPF_sp_ifftSPxSP_opt的参数和DSPF_sp_fftSPxSP参数设置差不多,有两个地方需要注意。
DSPF_sp_ifftSPxSP_opt parameters are the same as DSPF_sp_fftSPxSP except for the following two changes.
The twiddle factors are generated differently (see Section 2.3) and the output value is scaled by 1.0 / N as the definition of IFFT implies.
www.ti.com/…/sprac64.pdf

user4990482:

回复 Shine:

您好,首先谢谢您的回复,根据手册,我将旋转因子转为共轭,进行IFFT后结果依然不正确。

赞(0)
未经允许不得转载:TI中文支持网 » 关于DSPLIB中DSPF_sp_fftSPxSP_opt()、DSPF_sp_ifftSPxSP_opt()函数的使用问题
分享到: 更多 (0)