Skip to main content
deathclaw
Associate
June 12, 2011
Question

FFT problem

  • June 12, 2011
  • 1 reply
  • 718 views
Posted on June 12, 2011 at 21:42

I'm trying to calculate FFT of this signal (using Keil uVision and STM32F103VB:

0690X00000602inQAA.gif

but the result looks like this:

0690X00000602fQQAQ.jpg

Here's the code:

/////////////////////////////////////////////////////////////////

const int N=256;

void fft(){

int i;

uint16_t real[N], imag[N];

for(i=0; i<N; i++){

real[i]=(uint16_t)(data[i]);

imag[i]=0;

x[i] = (((uint16_t)(real[i])) | ((uint32_t)(imag[i]<<16)));

}

cr4_fft_256_stm32(y, x, N);

}

/////////////////////////////////////////////////////////////////

data is a float array containing the sine signal. Pictures above shows x and y arrays.

Could anyone tell me what I'm doing wrong?

Please help.

    This topic has been closed for replies.

    1 reply

    infoinfo989
    Associate III
    June 13, 2011
    Posted on June 13, 2011 at 22:06

    You haven't given us much to work with here.

    From looking at your first plot, a sine wave with values 50 to 250, it would appear your input data might possibly be a series of int's. However you state:

        ''data is a float array''

    Is it really? Your code casts the input data to int's:

        real[i]=(uint16_t)(data[i]);

    (I'm assuming data[i] is the input data)

    If your input data is incorrectly declared as floats, that would be a problem.

    What is the function prototype for:  cr4_fft_256_stm32(y, x, N);  ?

    What are your definitions for y and x?