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.

Starterware/TMDSLCDK6748: DSPF_sp_fftSPxSP in DSLIB produces wrong results

Part Number: TMDSLCDK6748
Other Parts Discussed in Thread: OMAPL138

Tool/software: Starterware

Hi,

The FFT function DSPF_sp_fftSPxSP in the DSPLIB produces wrong results. I am using the following hardware and software:

  • TMDSLCDK6748
  • CCS Version: 7.2.0.00013
  • processor_sdk_rtos_omapl138_4_00_00_04 (RTOS 4)
  • dsplib_c674x_3_4_0_0

I am using the provided FFT example: Benchmark_FFT_lcdkOMAPL138_c674ExampleProject that came with RTOS 4 and made the following changes:

        /* ---------------------------------------------------------------- */
        /* Initialize input vector temporarily.                             */
        /* ---------------------------------------------------------------- */
        for (i = 0; i < N; i++)
        {
//            x_cn[PAD + 2 * i]     = sin (2 * 3.1415 *  50 * i / (double) N);  //OLD
//            x_cn[PAD + 2 * i + 1] = sin (2 * 3.1415 * 100 * i / (double) N);  //OLD
            x_cn[PAD + 2 * i]     = sin(2.0 * PI * ((double)(i)) / (double)(8) );   //NEW
            x_cn[PAD + 2 * i + 1] = 0;                                              //NEW
			#if defined(_TMS320C6600)
            x_sa[PAD + 2 * i]     = x_cn[PAD + 2 * i];
            x_sa[PAD + 2 * i + 1] = x_cn[PAD + 2 * i + 1];
			#endif
            x_i [PAD + 2 * i]     = x_cn[PAD + 2 * i];
            x_i [PAD + 2 * i + 1] = x_cn[PAD + 2 * i + 1];
        }

and

        if (N <= 16)                                            //NEW
        {                                                       //NEW
            AUDIO_log("\n\nDSPF_sp_fftSPxSP, N=%d, radix=%d\n", //NEW
                      N, rad);                                  //NEW
            for(i = 0; i < (2 * N); i++)                        //NEW
            {                                                   //NEW
                AUDIO_log("Input x_i[%3d]=%14.6f\n",            //NEW
                          i, ptr_x_i[i]);                       //NEW
            }                                                   //NEW
        }                                                       //NEW
        DSPF_sp_fftSPxSP (N, &ptr_x_i[0], &ptr_w[0], ptr_y_i, brev, rad, 0, N);
        if (N <= 16)                                            //NEW
        {                                                       //NEW
            for(i = 0; i < (2 * N); i++)                        //NEW
            {                                                   //NEW
                AUDIO_log("Output y_i[%3d]=%14.6f\n",           //NEW
                          i, ptr_y_i[i]);                       //NEW
            }                                                   //NEW
        }                                                       //NEW

now the output of the program for N=8 is:

[C674X_0]  /* ---------------------------------------------------------------- */
 /* Single Precision FFT Benchmarks for N number of samples          */
 /* ---------------------------------------------------------------- */
DSPF_sp_fftSPxSP	Iter#: 1	

DSPF_sp_fftSPxSP, N=8, radix=2
Input x_i[  0]=      0.000000
Input x_i[  1]=      0.000000
Input x_i[  2]=      0.707107
Input x_i[  3]=      0.000000
Input x_i[  4]=      1.000000
Input x_i[  5]=      0.000000
Input x_i[  6]=      0.707107
Input x_i[  7]=      0.000000
Input x_i[  8]=      0.000000
Input x_i[  9]=      0.000000
Input x_i[ 10]=     -0.707107
Input x_i[ 11]=      0.000000
Input x_i[ 12]=     -1.000000
Input x_i[ 13]=      0.000000
Input x_i[ 14]=     -0.707107
Input x_i[ 15]=      0.000000
Output y_i[  0]=      0.000000
Output y_i[  1]=      0.000000
Output y_i[  2]=     -2.000000
Output y_i[  3]=     -2.000000
Output y_i[  4]=      0.000000
Output y_i[  5]=     -0.000000
Output y_i[  6]=      2.000000
Output y_i[  7]=      2.000000
Output y_i[  8]=      0.000000
Output y_i[  9]=      0.000000
Output y_i[ 10]=     -2.000000
Output y_i[ 11]=      2.000000
Output y_i[ 12]=      0.000000
Output y_i[ 13]=     -0.000000
Output y_i[ 14]=      2.000000
Output y_i[ 15]=     -2.000000
Intrinsic Successful 	N = 8	radix = 2	natC: 310	optC: 199465
DSPF_sp_fftSPxSP	Iter#: 2	

The input is a real signal: a sine with frequency= f_sample / 8. The frequency is chosen in such a way that we should get exact results:at frequencies f_sample / 8 and  7 *  f_sample / 8 we should get a value > 0 and all other frequencies should be 0. This means for N=8 and having a complex output array, the values with indices 2 & 3 and 14 & 15 should get a value > 0 and all other indices should be 0. But this is not the case: there are also values at indices 6 & 7 and 10 & 11 (frequencies 3 * f_sample / 8 and 5 * f_sample / 8).

What is wrong?

I realise that there are more efficient ways for an FFT on real signals, however, an FFT for complex signals should also work for real signals.

Remark: There is another problem and it occurs when the added print statements make the program slower. The following instructions need to be added to the beginning of main:

    /*
     *  Clear CSR and IER register.  This is necessary to prohibit interrupts
     *  from being enabled and left-over interrupts from being serviced.
     */
    __asm("\t  ZERO\t\t  B0");
    __asm("\t  MVC\t\t   B0, IER");
    __asm("\t  MVC\t\t   B0, CSR");

For more details see post "TMDSLCDK6748: Program from new CCS project hangs".

Best regards,

Ad