cancel
Showing results for 
Search instead for 
Did you mean: 

FFT implementation sinewave

luke514
Senior

Hi everyone. This is the first time I have to implement the FFT of a signal and I can't understand a few things.

I wrote this code that "should" calculate the coefficients of the FFT of a sine wave in that I create with the DAC (the DAC code to generate sinewave works, I measured it with oscilloscope) and I kindly ask for some opinions on how to solve these 3 problems:

1) The warning in the FFT instruction arm_rfft_fast_f32 that says: "passing arguments 2 and 3 of 'arm_rfft_fast_f32' from incompatible pointer type"

2) If the code below that I wrote to calculate fftBufOut, in which the real and complex coefficients of the FFT of the sine wave should be present, is correct

3) I don't see the coefficients inside fftBufOut right in the "Expressions" tab .. why?

 

Below there are the only lines of code I wrote in the entire project:

/* USER CODE BEGIN PD */
#define FFT_BUFFER_SIZE 2048

arm_rfft_fast_instance_f32 fftHandler;
float fftBufIn[FFT_BUFFER_SIZE];
float fftBufOut[FFT_BUFFER_SIZE];
uint8_t fftIndex = 0;
uint8_t fftFlag = 0;
/* USER CODE END PD *
void get_sineval_FFT() {

int i = 0;

//-----------------------------------------------------------------------------------------------
for (i = 0; i < FFT_BUFFER_SIZE; i++) {
sine_val[i] = ((sin(i*2*PI/samples) + 1)*(4096/2)); //100Hz

fftIndex++;

if (fftIndex == FFT_BUFFER_SIZE) {
//perform FFT
arm_rfft_fast_f32(&fftHandler, &sine_val, &fftBufOut, 0);
fftFlag = 1;
fftIndex = 0; //reset FFT array index
}

}
//-----------------------------------------------------------------------------------------------
}

...below there is an empty main with while(1);

 

 

 

1 REPLY 1
KnarfB
Principal III

1) type float32_t* expected, see the docs https://www.keil.com/pack/doc/CMSIS/DSP/html/

2) "in which the real and complex coefficients of the FFT " real and imaginary, right. Except for the first pair which holds DC and Nyquist coeff, both real.

3) are the arrays global? If not, the result may be optimized away because it is not used.

Must also call arm_rfft_fast_init_f32 beforehand.

hth

KnarfB