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.

TMS320C5535: 利用1024FFT库函数计算2048点FFT结果不对

Part Number: TMS320C5535

根据手册中提供的Greater Than 1024-point FFT代码计算2048点FFT,奇偶序列FFT后组合的结果不对,手册中没有提供

CPLX_Mul(twiddle[k], data_odd[k])。

CPLX_Add(data_even[k], twiddle_times_data_odd, SCALE_FLAG);,

CPLX_Subtract(data_even[k], twiddle_times_data_odd, SCALE_FLAG)

这三个函数的代码。请看一下编写的这三个函数有什么问题,CPLX_Mul这个函数中两个int16的数相乘再移位会造成符号位跟着右移,请问有没有正确的代码

Int32 CPLX_Mul(Int32 op1, Int32 op2)
{
	Int16 op1_r, op1_i, op2_r, op2_i;
	Int32 op1_op2_r, op1_op2_i;
	Int16 op1_op2_r16, op1_op2_i16;
	Int32 cplx_prod;

	// Mask data for real and imag data = (real:imag)
	op1_r = op1 >> 16;
	op1_i = op1 & 0x0000FFFF;
	op2_r = op2 >> 16;
	op2_i = op2 & 0x0000FFFF;

	op1_op2_i	= (Int32)op1_r*op2_i + (Int32)op1_i*op2_r;
	op1_op2_r	= (Int32)op1_r*op2_r - (Int32)op1_i*op2_i;
	
	op1_op2_i16 = (Int16)(op1_op2_i >> 15);
	op1_op2_r16 = (Int16)(op1_op2_r >> 15);

	cplx_prod = (((Int32)op1_op2_r16 & 0x0000FFFF)<< 16);
	cplx_prod = cplx_prod | ((Int32)op1_op2_i16 & 0x0000FFFF);

	return cplx_prod;
}
Int32 CPLX_Add(Int32 op1, Int32 op2 , Uint16 scale_flag)
{
    Int16 op1_r, op1_i, op2_r, op2_i;
    Int32 op1_op2_r, op1_op2_i;
    Int16 op1_op2_r16, op1_op2_i16;
    Int32 cplx_prod;

    // Mask data for real and imag data = (real:imag)
    op1_r = op1 >> 16;
    op1_i = op1 & 0x0000FFFF;
    op2_r = op2 >> 16;
    op2_i = op2 & 0x0000FFFF;

    // Yr = 1/2 * (op1_r + op2_r), Yi = 1/2 *(op1_i + op2_i)
    op1_op2_i   = (Int32)op1_i +(Int32)op2_i;
    op1_op2_r   = (Int32)op1_r +(Int32)op2_r;

    op1_op2_i16 = (Int16)(op1_op2_i >> 1);
    op1_op2_r16 = (Int16)(op1_op2_r >> 1);


    cplx_prod = (((Int32)op1_op2_r & 0x0000FFFF)<< 16);
    cplx_prod = cplx_prod | ((Int32)op1_op2_i & 0x0000FFFF);

    return cplx_prod;
}

Int32 CPLX_Subtract(Int32 op1, Int32 op2 , Uint16 scale_flag)
{
    Int16 op1_r, op1_i, op2_r, op2_i;
    Int32 op1_op2_r, op1_op2_i;
    Int16 op1_op2_r16, op1_op2_i16;
    Int32 cplx_prod;

    // Mask data for real and imag data = (real:imag)
    op1_r = op1 >> 16;
    op1_i = op1 & 0x0000FFFF;
    op2_r = op2 >> 16;
    op2_i = op2 & 0x0000FFFF;

    // Yr = 1/2 * (op1_r - op2_r), Yi = 1/2 *(op1_i - op2_i)
    op1_op2_i   = (Int32)op1_i - (Int32)op2_i;
    op1_op2_r   = (Int32)op1_r - (Int32)op2_r;

    op1_op2_i16 = (Int16)(op1_op2_i >> 1);
    op1_op2_r16 = (Int16)(op1_op2_r >> 1);

    cplx_prod = (((Int32)op1_op2_r & 0x0000FFFF)<< 16);
    cplx_prod = cplx_prod | ((Int32)op1_op2_i & 0x0000FFFF);

    return cplx_prod;
}
请问一下有没有计算正确的这三个函数。

www.ti.com.cn/.../spruh87h.pdf