AnsweredAssumed Answered

FFT Problem in Loop STM32F4-Disco

Question asked by Tarkan Dalay on Jun 24, 2017
Latest reply on Jan 16, 2018 by Clive One

Hi folks;

I want to use fft (1024) in my signal which came from i2s, so it's should be real time. I'm new at fft, there may be some mistakes. And sorry for my bad english

When i use fft without loop everything works fine;

void main(){

.....

arm_cfft_f32(&CFFT_LENGTH,wave_buffer,ifft_Flag,doBitReverse);
arm_cmplx_mag_f32(wave_buffer,fft_Output,fft_Size);
arm_max_f32(fft_Output,fft_Size,&MaxValue,&testIndex);

....
    while(1){
       
        ....

    }
}

But in loop, i have a trouble, as in the picture;

*memcpy for refresh buffer or new data inputs

 

 

void main(){

.....

....
    while(1){

        memcpy(&wave_buffer,&wave_Input,2048);

        arm_cfft_f32(&CFFT_LENGTH,wave_buffer,ifft_Flag,doBitReverse);
        arm_cmplx_mag_f32(wave_buffer,fft_Output,fft_Size);
        arm_max_f32(fft_Output,fft_Size,&MaxValue,&testIndex);
       
        ....

    }
}

I solved this problem but i had new one. First value is right, others isn't.

void main(){

.....

    memcpy(&wave_buffer,&wave_Input,2048);
    arm_cfft_f32(&CFFT_LENGTH,wave_buffer,ifft_Flag,doBitReverse);
    while(1){
        counter++;
        if(counter%2==0){
            memcpy(&wave_buffer,&wave_Input,SAMPLES);
            max_freq=(48800/1024)*testIndex;
            arm_cmplx_mag_f32(wave_buffer,fft_Output,fft_Size);    
            arm_max_f32(fft_Output,fft_Size,&MaxValue,&testIndex);
        }
        else{
            memcpy(&wave_buffer,&wave_3_440Hz_44100,SAMPLES);
            max_freq=(44100/1024)*testIndex;
            arm_cmplx_mag_f32(wave_buffer,fft_Output,fft_Size);    
            arm_max_f32(fft_Output,fft_Size,&MaxValue,&testIndex);
        }    
   
        .....
    }
}

Question-1: Why frequency values changed unexpectedly? (terminal picture-1)

Question-2: Why frequency values isn't equals reference values? (terminal picture-2)

 

Board:STM32F4-Discovery

*I used the calculations on this link;

Introduction - FFT Size 

*review CMSIS DSP_Lib/Examples

*some codes written with "arm_status arm_cfft_radix4_init_f32" 

I read this "Do not use this function. It has been superceded by arm_cfft_f32 and will be removed in the future."

in CMSIS-DSP_Lib 1.4.7, so i didn't use radix4 functions.

 

Best Regards.

Outcomes