cancel
Showing results for 
Search instead for 
Did you mean: 

How to use ARM_MATH FFT

jogerh
Associate II
Posted on April 20, 2017 at 10:55

Dear Community,

I want to use the arm package: arm_cfft_radix4 to perform a 1K FFT repetitively in a loop on a STM32F407 device. To do so I predefined: __FPU_PRESENT=1,ARM_MATH_CM4 and added the library arm_cortexM4lf_math.lib to my project.

For investigating the arm_fft I copied testcode from:

https://community.st.com/external-link.jspa?url=https%3A%2F%2Fstm32f4-discovery.net%2F2014%2F10%2Fstm32f4-fft-example%2F%3A

#define FFT_SIZE 1024

arm_cfft_radix4_instance_f32 S;

//get some test data:

for (count = 0; count < FFT_SIZE; count ++) {

                        Input[count] = 10* arm_sin_f32(count*PI_loc/ 10);     

}

arm_cfft_radix4_init_f32(&S, FFT_SIZE, 0, 1);

// execute the fft repetit

while(1) {                                         

                       // Process the data through the CFFT/CIFFT module

                        arm_cfft_radix4_f32(&S, Input);      

                        // Process the data through the Complex Magniture Module for calculating the magnitude at each bin

                        arm_cmplx_mag_f32(Input, Output, FFT_SIZE);

                        -> SEND Output to Display

}

However it works just for one times – during all subsequent cycles Output contains nothing. I would be very happy if someone would give a hint.

2 REPLIES 2
jogerh
Associate II
Posted on April 20, 2017 at 11:28

Dear Community,

looks like the buffers: “Input� and “Output� are used for intermediate storage by the arm_math functions: arm_cfft_radix4_f32 and arm_cmplx_mag_f32. After increasing the buffersize up to 2*FFT_SIZE and zeroing each & memcpy new rawdata to “Input� each cycle, the FFT seem to work – in my case it requires 900 µs @ 144 MHz clock speed. The AN4841 appnote states FFT will take only 547 µs - however I think this can be attributed to a difference of the clock speed used for the benchmark (216 MHz).

AvaTar
Lead
Posted on April 20, 2017 at 11:43

Does your second post indicate it works now for you ?

However, there used to be complete FFT examples in the DSP_Libs distributed especially for the F3 and F4 parts.

I think the are still available, even if 'SPL-based'.

And even if not, most of the DSP lib code, especially this FFT example, comes from ARM directly, and can be downloaded elsewhere.