AnsweredAssumed Answered

rfft2048 issue

Question asked by dramsay on May 19, 2011
Latest reply on Jun 25, 2013 by Vaios

Hey, I'm working on a 21262 EZ-kit, trying to implement a basic FFT magnitude plot.  I've successfully gotten an rfft512 working, and the spectrum looks beautiful.  Now that I've been trying to get an rfft2048 working using the same code- which compiles and gives no errors- the spectrum and the input are both filled with #1.QNAN.

 

I checked that the input being read into the fft was correct, and it looks perfect (attached it a picture of the sin wave being read from the input array before the fft function call- this is taken using the attached code and a signal generator running at 468.75 Hz, which should fall perfectly into the 20th bin).

 

I had some help earlier on the forums reassigning memory- could a lack of heap memory cause this problem?  Any idea as to what is going on?  Any help is much appreciated.  Attached is my code, and below pasted is the relevant section:

 

####IN HEADER#####

 

#define NUM_SAMPLES 1024

#define N_FFT 2048

#define N_RFFT_OUT ((N_FFT / 2) + 1)

 

####IN BLOCK PROCESS ROUTINE####

 

#include "tt.h"
#include <filter.h>
#include <math.h>

 

int count;
int i;

 

float input[N_FFT];
float temp[N_FFT];
complex_float output[N_RFFT_OUT - 1];

 

float spectrum[N_RFFT_OUT - 1];
                                              
void processBlock(unsigned int *block_ptr, unsigned int *block_ptr1, unsigned int *block_ptr2, unsigned int *block_ptr3)
{
    newData = 0; //resets the indicator for new data, must be first line in this routine
    count = 0;
  
    for(i=0;i<NUM_SAMPLES;i+=2)
        {
              input[count++] = (float)(int)(*(block_ptr+i)<<8);
           }
  
    for(i=0;i<NUM_SAMPLES;i+=2)
        {
              input[count++] = (float)(int)(*(block_ptr+i)<<8);
        }
  
    for(i=0;i<NUM_SAMPLES;i+=2)
        {
              input[count++] = (float)(int)(*(block_ptr+i)<<8);
        }
          
   for(i=0;i<NUM_SAMPLES;i+=2)
        {
              input[count++] = (float)(int)(*(block_ptr+i)<<8);
        }
  
       for(i=0;i<N_FFT;i++)
           {
           temp[i] = input[i];   
           } 
       
    rfft2048(input, output);
    fft_magnitude(output, spectrum, N_FFT, 1);
          
       
}

Attachments

Outcomes