2024-06-06 05:03 AM - edited 2024-06-06 05:23 AM
I am trying to calculate the FFT using CMSIS-DSP.
I downloaded the latest CMSIS-DSP from github, copied folders CMSIS\DSP\Include, CMSIS\DSP\PrivateInclude and CMSIS\DSP\Source in my Drivers folder, added CMSIS\DSP\Include and CMSIS\DSP\PrivateInclude to my include path and removed all .c files in CMSIS\DSP\Source that does not have _f32 in the filename, since I am planning to use only float32 data.
My project is build with STM32CubeIDE and the microcontroller is a STM32L476RG.
The symbol ARM_MATH_CM4 is defined.
This is the code I'm trying to use:
#include "arm_math.h"
#include "arm_const_structs.h"
#define SAMPLES_NUMBER 1024
/* ----------------------------------------------------------------------
* Max magnitude FFT Bin calculation
*
* the input vector must be 1024 elements
* ------------------------------------------------------------------- */
float32_t fft(float32_t *input_vector, uint32_t sampling_rate)
{
float32_t maxValue;
uint32_t maxIndex;
float32_t frequency;
float32_t output_vector[SAMPLES_NUMBER / 2];
arm_cfft_instance_f32 fft_handler;
arm_status status;
status = ARM_MATH_SUCCESS;
// Init FFT module
status = arm_cfft_init_1024_f32(&fft_handler);
if (status != ARM_MATH_SUCCESS)
{
Error_Handler();
}
// Process the data through the CFFT/CIFFT module
arm_cfft_f32(&fft_handler, input_vector, 0, 1);
// Process the data through the Complex Magnitude Module to calculate the magnitude at each bin
arm_cmplx_mag_f32(input_vector, output_vector, SAMPLES_NUMBER / 2);
// Calculates maxValue and returns corresponding BIN value
arm_max_f32(output_vector, SAMPLES_NUMBER / 2, &maxValue, &maxIndex);
// Calculates the frequency corresponding to the max BIN value
frequency = (float32_t)maxIndex * (float32_t)sampling_rate / (float32_t)SAMPLES_NUMBER;
return frequency;
}
When I compile I get the following error:
conflicting types for 'clip_q63_to_q31'; have 'q31_t(q63_t)' {aka 'long int(long long int)'}
in file none.h
I noticed that none.h is included in arm_math.h, besides a lot of other include files.
What am I doing wrong?
Solved! Go to Solution.
2024-06-06 09:03 AM
I already did the CMSIS-DSP integration, but somehow the CubeIde marked some folders out of compilation, so even if I had the arm_math.h in my include path and in my code, it was not considering it and I got that error.
Once I removed the filter that disabled the compilation everything worked.
2024-06-06 05:47 AM
Hello @Manuel Ferrero ,
To integrate the latest CMSIS-DSP libraries on a STM32 project using STM32CubeIDE toolchain. I recommend you to follow the steps shared in this FAQ: How to integrate CMSIS-DSP libraries on a STM32 project.
I hope this help you.
Please let me know if the issue is solved or not?
Thank you.
Kaouthar
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.
2024-06-06 09:03 AM
I already did the CMSIS-DSP integration, but somehow the CubeIde marked some folders out of compilation, so even if I had the arm_math.h in my include path and in my code, it was not considering it and I got that error.
Once I removed the filter that disabled the compilation everything worked.