2017-06-24 02:09 AM
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, ihave 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 isright, 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
valueschanged 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;
http://support.ircam.fr/docs/AudioSculpt/3.0/co/FFT%20Size.html
*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.
#armcm4.h-arm_math.h #fft2018-01-16 01:38 AM
Hello,
I am also using same procedure for FFT. I am using ADC values for FFT input but I am not getting random value of frequency. I am reading ADC value using DMA at sampling rate of 8000 hertz.
how can I solve this problem?
Thanks in advance.
Regards,
Mohit rai
2018-01-16 09:29 AM
Hi
rai.mohit
,Try to use the FFT example available in
http://www.st.com/en/embedded-software/x-cube-dspdemo.html
. It runs on STM32F429I-DISCO & STM32F746-DISCO. You can refer to AN4841 to get more idea about the usage of this package besides to the expected results.-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2018-01-16 10:48 AM
>>how can I solve this problem?
Start by understanding the source of the problem.
Make test cases using data sets you can test on the STM32 platform and on a PC platform.
2018-01-16 11:02 AM
Thank you for reply.
2018-01-16 11:17 AM
Hello,
Thank you for your response. I have generated 500 Hertz sin wave(with DC offset 2047 or without DC offset ) in matlab and perform the fft on the same data.when DC offset shift data is used for FFT, my index is 0 . And for without DC shift DC data, my index is right.
Is DC shift affecting my FFT calculation?
I have tried same procedure with ADC data (ADC data is microphone value). index is changing randomly.
Thanks
Regard,
Mohit Rai
2018-01-16 12:07 PM
My concern with ADC+DMA acquired samples is that the data buffers can change during the execution time of the function. You should test and validate static data sets with the ARM routines, I believe DSP library routines are provided in source form.