DSPRelated.com
Forums

wrong output for TI DSP_fft function

Started by mili...@gmail.com October 13, 2010
The function I am using is from Texas Instruments Little Endian DSPLIB : void DSP_fft(const short *w, int nsamp, short *x, short *y).

Twiddle factors are calculated with tw_fft16x16.c code.

x,y and w are double-word aligned as requested.

When I use 32-point FFT for all zero input signal, as output I get this:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1500 6553 29596 -18457 0 0 28160 4224 0 0 0 0 0 0 0 0 -7424 -17716 -25686 -30574 8192 0 -24064 4224 0 0 0 0 0 0 0 0 8224 8224 8224 8224 8224 8224 8224 8224
Does anybody know the reason why?

_____________________________________
Milica-

> The function I am using is from Texas Instruments Little
> Endian DSPLIB : void DSP_fft(const short *w, int nsamp,
> short *x, short *y).
>
> Twiddle factors are calculated with tw_fft16x16.c code.
>
> x,y and w are double-word aligned as requested.
>
> When I use 32-point FFT for all zero input signal, as
> output I get this:
>
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1500 6553 29596 -18457 0 0 28160 4224 0 0 0 0 0 0 0 0 -7424 -17716
> -25686 -30574 8192 0 -24064 4224 0 0 0 0 0 0 0 0 8224 8224 8224 8224 8224 8224 8224 8224

Suggest to search archives on dsprelated.com for "DSP_fft" and you should find a lot of discussion. Some typical
"gotchas" include:

-circular buffers may need to be located
at a mem address that has some minimum
number of lsb zeros

-data alignment (may need to be to
multiple-of-4 or multiple-of-8)

-test first with no compiler optimizations

Your approach is good though: first try with all zero input, then try with something that will give you a "known"
output, such as real values 1,0,0,... and imag values all zero.

-Jeff

_____________________________________
The function I am using is from Texas Instruments Little Endian DSPLIB : void DSP_fft(const short *w, int nsamp, short *x, short *y).
>
>Twiddle factors are calculated with tw_fft16x16.c code.
>
>x,y and w are double-word aligned as requested.
>
>When I use 32-point FFT for all zero input signal, as output I get this:
>
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1500 6553 29596 -18457 0 0 28160 4224 0 0 0 0 0 0 0 0 -7424 -17716 -25686 -30574 8192 0 -24064 4224 0 0 0 0 0 0 0 0 8224 8224 8224 8224 8224 8224 8224 8224
>Does anybody know the reason why?
>
>_____________________________________

Thank you, Jeff, for your reply.

When the output of twiddle16x16.exe is written to a text file, one can see that it´s explicitly written that one must align data to 8-byte boundaries. Nevertheless, I tried with 4-byte boundaries - it didn´t work.

I wasn´t using any optimizations in the first place.

I also searched the dsprelated.com and read lots of articles, but none of them helped.

I am open to other suggestions :)

_____________________________________
The function I am using is from Texas Instruments Little Endian DSPLIB : void DSP_fft(const short *w, int nsamp, short *x, short *y).
>
>Twiddle factors are calculated with tw_fft16x16.c code.
>
>x,y and w are double-word aligned as requested.
>
>When I use 32-point FFT for all zero input signal, as output I get this:
>
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1500 6553 29596 -18457 0 0 28160 4224 0 0 0 0 0 0 0 0 -7424 -17716 -25686 -30574 8192 0 -24064 4224 0 0 0 0 0 0 0 0 8224 8224 8224 8224 8224 8224 8224 8224
>Does anybody know the reason why?
>
>_____________________________________
When I tried a different function: DSP_fft16x16t(const short * ptr_w, int npoints, short * ptr_x, short * ptr_y), it worked fine.

Then I looked at tw_fft16x16.c and saw that they specified that appropriate FFTs are DSP_fft16x16r and DSP_fft16x16t. So, the problem was that I was using the wrong programme for twiddle factors for this function. The reason I used tw_fft16x16.c in the first place is that they said so in the TMS320C64x DSP Library Programmer’s Reference (SPRU565A) when they specified Special Requiremnts for DSP_fft function.

Anyway, thanks for your help.

_____________________________________
Milica-

> The function I am using is from Texas Instruments Little
> Endian DSPLIB : void DSP_fft(const short *w, int nsamp, short
> *x, short *y).
>>
>>Twiddle factors are calculated with tw_fft16x16.c code.
>>
>>x,y and w are double-word aligned as requested.
>>
>>When I use 32-point FFT for all zero input signal, as output
> I get this:
>>
>> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1500 6553 29596 -18457 0 0 28160 4224 0 0 0 0 0 0 0 0 -7424 -17716
>> -25686 -30574 8192 0 -24064 4224 0 0 0 0 0 0 0 0 8224 8224 8224 8224 8224 8224 8224 8224
>>Does anybody know the reason why?
>>
>>_____________________________________
> When I tried a different function: DSP_fft16x16t(const
> short * ptr_w, int npoints, short * ptr_x, short * ptr_y),
> it worked fine.
>
> Then I looked at tw_fft16x16.c and saw that they specified
> that appropriate FFTs are DSP_fft16x16r and DSP_fft16x16t.
> So, the problem was that I was using the wrong programme
> for twiddle factors for this function. The reason I used
> tw_fft16x16.c in the first place is that they said so in
> the TMS320C64x DSP Library Programmer's Reference
> (SPRU565A) when they specified Special Requiremnts for
> DSP_fft function.

Very glad to hear you got it working.

It seems that gen_twiddle() might be the appropriate function when using DSP_fft(). Here is one thread I found where
the author says he got both DSP_fft() and DSPfft16x16t() to work:

http://www.dsprelated.com/groups/c6x/show/9994.php

-Jeff

_____________________________________