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

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.

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?