I am trying to implement a real time FFT/iFFT code on the C6713 DSK. I am a EE student still learning C programming, so there are some aspects of programming I am not too familiar with. I am am using the dsk_app program as a template and adding the FFT function inside the 'processBuffer()' loop. I think something is causing me to get bad data in the FFT loop. When I view the memory location of the "x" buffer, I see 1.#QNAN for every value. From reading I think that it is a problem with the FFT function being interrupted during processing, but I don't know if I do global int disable on each side of the FFT functions if this will fix the problem. From my understanding, the dsplib FFT functions already do this in the assembly code. I have attached the part of the code I am referring to.
void processBuffer(void)
{
Uint32 pingPong;
/* Get contents of mailbox posted by edmaHwi */
pingPong = SWI_getmbox();
/* Copy data from transmit to receive, could process audio here */
if (pingPong == PING) {
for( i = 0 ; i < FFTSIZE/RADIX ; i++ ) //Create twiddle array
{
W[i].re = cos(DELTA*i); //real component of W
W[i].im = sin(DELTA*i); //neg imag component
}
digitrev_index(iTwid, FFTSIZE/RADIX, RADIX); //obtain index for bitrev()W
bitrev(W, iTwid, FFTSIZE/RADIX); //bit reverse W
for(i=0; i<FFTSIZE/2; i++) //initialize Xmag array
{
Xmag[i] = 0;
}
for( i = 0 ; i < FFTSIZE/2 ; i++ )
{
//window = -.5*cos(2.*PI*(i/FFTSIZE))+.5;
x[i].re = gBufferRcvPing[i];//*window; //external input
x[i].im = 0.0; //zero imaginary part
}
//init output magnitude
cfftr2_dit(x, W, FFTSIZE) ; //TI floating-pt complex FFT
for( i = 0; i < FFTSIZE/2; i++) //preserve non-br fft array
{
intermediate[i].re = x[i].re; //for ifft routine
intermediate[i].im = x[i].im;
}
digitrev_index(iData, FFTSIZE, RADIX); //produces index for bitrev() X
bitrev(x, iData, FFTSIZE); //freq scrambled->bit-reverse x
icfftr2_dif(intermediate,W,FFTSIZE);
for (i =0; i<FFTSIZE/2; i++)
{
gBufferRcvPing[i] = intermediate[i].re;
}
for(i = 0; i < FFTSIZE/2; i++)
Xmag[i] = sqrt(x[i].re*x[i].re+x[i].im*x[i].im)/32;
/* Copy receive PING buffer to transmit PING buffer */
copyData(gBufferRcvPing, gBufferXmtPing, BUFFSIZE);