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.

Error in dsplib (DSP62x.lib)

Hello all.

For an old 6202 device, I need to use the dsplib function DSP_fft16x16r, however the results I get are wrong. We are using "the same" function in an c6416 dsp (of course from  dsp64x.lib), and in this platform we get the expected output.

We have tripled checked:

- the twiddle factors: we used the tw_fft16x16.exe file to generate those (const short w_16x16[2 * 510] ={......})

- the data align:#pragma DATA_ALIGN(w_16x16, 8);

- the call of the function:

DSP_fft16x16r(512, XX, w_16x16, brev, Y_16, 2, 0, 512);

Has anybody faced an issue like this? Does TI know about this issue?

Thank you.

Best Regards

  • This is a clear example of what I am talking about:

    - XX is the complex input data

    - ZZ_16 is the exit of the DSP_fft16x16r in dsp62x.lib

    - M2 is the magnitude of that FFT

    Do you know why the output is like this?

    Thank you.

  • And this is the output when I use a different fft function from another code. A clean but slow frequency carrier:

    Any comment from TI about this?

  • No answer yet,  as we all expected 

  • No way nobody from TI hasn't read this!!

  • Anything to say?

  • PAk SY said:
    Do you know why the output is like this?

    From looking at the screen capture of the "XX" complex input data there appear to be discontinuities / glitches in the time domain signals. i.e. maybe the M2 is the expected FFT output given the input data.

    Can you try passing the same XX complex input data through a PC implementation of the FFT to see what the results are. i.e. to check if the problem is in the DSP_fft16x16r in dsp62x.lib implementation or not.

  • Chester Gillon said:

    From looking at the screen capture of the "XX" complex input data there appear to be discontinuities / glitches in the time domain signals. i.e. maybe the M2 is the expected FFT output given the input data.

    Can you try passing the same XX complex input data through a PC implementation of the FFT to see what the results are. i.e. to check if the problem is in the DSP_fft16x16r in dsp62x.lib implementation or not.

    Thank you for your answer Chester.

    However those discontinuities / glitches are translated into frequency as sinc functions during time, they do not affect the tone FFT output.

    Realize, that the second graph also has those glitches and the FFT ouput is ok. It is the library functions.

  • Answer from the TI via Contact us:

    Dear XXXXX

    Thank you for contacting Texas Instruments. 

     

    In order to resolve your inquiry, we would kindly advise you to contact one of our official distributors who have their own support portal into Texas Instruments.

     

    Alternatively, we would advise you to utilize the knowledge and experience available on our e2e forum.  Our e2e community is constantly reviewed and managed by TI specialists according to product and is further supported by over 50,000 engineers from around the world sharing their knowledge and experience.  If you are already a member of our e2e community, you can post your question directly on our e2e community.

     

    If you are not yet a member of our e2e community, please click here and follow the instructions to become a member.

     

    For additional online assistance, please visit our Technical Support KnowledgeBase homepage at: http://support.ti.com/sc/knowledgebase 

    Kind Regards,

    ASKTEXAS Team
    Texas Instruments
    www.ti.com/asktexas

    Dead End or Infinite loop??

  • bump!! (Until it is actually answered)

  • Hey,

        I am facing same problem. Can you guide me how you solved this problem?

  • Same problem with dsplib 62x V1.04a.

    Here is one example program to demonstrate failures: 

    /* ffttry1.c */
    
    /*
    
    
    	This program ttry to use dsplib fft functions 
    
    	by Zsolt Kenid (kzsoltkzsolt@freemail.hu)
    	
    	
    */
    
    
    /* 
    
    	To cehck input signal use View/Graph/Time_Frequency with paremeters below: 
    
    		FFT Magnitude, "", Real, pxy, nsample, 2, 256, 8, Receatgle, Off, 16bit signed integer, 0, 8000 
    		
    */
    
    /*
    
    	The result is wrong.
    	
    	For example for 500Hz sine DSP_fft16x16r() respond with 500, 1500, 2500, 3500Hz result, 
    	and its calculated amplitde total garbled.
    	For diffrent frequency we got diffrent garbled result.  
    	For diffrent amplitude we got diffrent garbled result.  
    	
    */
    
    #include <std.h>
    #include <log.h>
    #include <mem.h>
    #include <math.h>
    
    #include <dsp_fft16x16r>
    
    #ifndef PI
    # ifdef M_PI
    #  define PI M_PI
    # else
    #  define PI 3.14159265358979323846
    # endif
    #endif
    
    
    /* missing */
    extern far LOG_Obj trace;
    extern const int SDRAM;
    
    
    /* simulated header above */
    
    
    const Int samplef = 8000;		/* sample frequency */
    const Int nsample = 64;			/* number of samples codec-DSP */
    const Int samplewide = 16;		/* wide of pone sample */
    
    Int xysize = 0;  
    Int wsize = 0;
    short *pxy;
    short *py;
    short *pw;
    
    
    /* bit reverese contatn table for DSP_fft16x16r */
    unsigned char brev_oxor[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
    	};
    
    
    /* ======================================================================== */
    /*  GEN_TWIDDLE -- Generate twiddle-factor array for TI's custom FFTs.      */
    /*  radix X version 	                                                    */
    /*  for DSP_fft, DSP_fft16x16r and DSP_fft16x16t FFT library routines       */
    /*                                                                          */
    /*  USAGE                                                                   */
    /*      This routine is called as follows:                                  */
    /*                                                                          */
    /*          int gen_twiddle_rx(short *w, int n, double scale)               */
    /*                                                                          */
    /*          short  *w     Pointer to twiddle-factor array                   */
    /*          int    n      Size of FFT                                       */
    /*          double scale  Scale factor to apply to values.                  */
    /*                                                                          */
    /*      The routine will generate the twiddle-factors directly into the     */
    /*      array you specify.  The array needs to be approximately 2*N         */
    /*      elements long.  (The actual size, which is slightly smaller, is     */
    /*      returned by the function.)                                          */
    /* ======================================================================== */
    
    /*  D2S -- Truncate a 'double' to a 'short', with clamping.                 */
    static short gen_twiddle_d2s(double d)
    	{
        if (d >=  32767.0) return  32767;
        if (d <= -32768.0) return -32768;
        return (short)d;
    	}
    
    int gen_twiddle_rx(short *w, int n, double scale)
    	{
        int i, j, k;
    
        for (j = 1, k = 0; j < n >> 2; j = j << 2)
        {
            for (i = 0; i < n >> 2; i += j << 1)
            {
                w[k + 11] = gen_twiddle_d2s(scale * cos(6.0 * PI * (i + j) / n));
                w[k + 10] = gen_twiddle_d2s(scale * sin(6.0 * PI * (i + j) / n));
                w[k +  9] = gen_twiddle_d2s(scale * cos(6.0 * PI * (i    ) / n));
                w[k +  8] = gen_twiddle_d2s(scale * sin(6.0 * PI * (i    ) / n));
    
                w[k +  7] = gen_twiddle_d2s(scale * cos(4.0 * PI * (i + j) / n));
                w[k +  6] = gen_twiddle_d2s(scale * sin(4.0 * PI * (i + j) / n));
                w[k +  5] = gen_twiddle_d2s(scale * cos(4.0 * PI * (i    ) / n));
                w[k +  4] = gen_twiddle_d2s(scale * sin(4.0 * PI * (i    ) / n));
    
                w[k +  3] = gen_twiddle_d2s(scale * cos(2.0 * PI * (i + j) / n));
                w[k +  2] = gen_twiddle_d2s(scale * sin(2.0 * PI * (i + j) / n));
                w[k +  1] = gen_twiddle_d2s(scale * cos(2.0 * PI * (i    ) / n));
                w[k +  0] = gen_twiddle_d2s(scale * sin(2.0 * PI * (i    ) / n));
    
                k += 12;
            }
        }
    
        return k;
    	}
    	
    void printva(LOG_Handle logd,void *pvar,char *pbname)
    	{
    	unsigned int tmpu;
    	tmpu = (unsigned int)pvar;	/* for conversion, start of output */
    	/* no other way because LOG_printf has only two arg... */
    	LOG_printf(logd, "%s var at 0x%x",pbname,tmpu);
    	}
    
    Void gentestsine(short *pxy,Int nsample,Uns fmult, short psval, int phase)
    	{
    	Uns sct;
    	float aet,avt,ifmult=(1.0/fmult);
    		
    	for(sct=0;sct<nsample;sct++)
    		{
    		aet = (2.0*PI*sct*ifmult);
    		avt = (phase*PI/180.0);
    		*pxy = psval * sinf( aet - avt );	/* real part */
    		pxy+=1; 
    		*pxy = 0;	/* imaginere part (0 beacuse real ADC) */
    		pxy+=1;
    		}
    	}
    
    
    Void main()
    	{
     
    	LOG_printf(&trace, "Program FFT try 1 started!!");
    	
    	xysize = (nsample * 2 * sizeof(short));  
    	wsize = nsample;
    
    	
    	pxy = MEM_alloc( SDRAM, xysize , (2 * sizeof(int)) );
    	py = MEM_alloc( SDRAM, xysize , (2 * sizeof(int)) );
    	pw = MEM_alloc( SDRAM, wsize , (2 * sizeof(int)) );
    	gen_twiddle_rx(pw, nsample, 32767.5);
    
    	/* generate test sine */
    	gentestsine(pxy,nsample,16, 0x1600, 0);	/* f = sf / 16, a = +-0x1600, ph= 0 */
    	
    	/* do fft */
    	DSP_fft16x16r(nsample, pxy, pw, &brev_oxor[0], py, 4, 0, nsample);
    	
    	printva(&trace,py,"fft result");
    	
    	return;
    	}
    	
    
    .

    According our experience result of DSP_fft16x16r always worng.

    It remarkable, "DSP_fft16x16t: Fixed a CSR bug. Wrong CSR was restored." update is applied to dsp64x library, but not applied to dsp62x library. Maybe this is a key for different result...

  • After many tests, the problem is in support file not in library. DSP_fft16x16t work fine if used together with tw_gen() of C62xx library. Located in library source (dsp62x_c.src).  

  • Kendi Zsolt said:

    After many tests, the problem is in support file not in library. DSP_fft16x16t work fine if used together with tw_gen() of C62xx library. Located in library source (dsp62x_c.src).  

    Thank you Kendi for your effort and sharing your results. A 10 years bug has been solved, even with no TI help.

    I am sure many people will benefit from your answer.