2024-11-08 10:06 AM - edited 2024-11-08 10:08 AM
Hey I am trying to use CMSIS DSP library to perform FFT of i2s data from a mic but it is showing error after using the FFT functions but is compling if only library is added is there any thing I have missed
this is the code:
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "arm_math.h"
#include "arm_const_structs.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
I2S_HandleTypeDef hi2s1;
/* USER CODE BEGIN PV */
#define FFT_size 256
q15_t buf[FFT_size];
q15_t input_signal[FFT_size];
q15_t Complex[2*FFT_size];
q15_t Real[FFT_size];
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_I2S1_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void FFT_compute(){
arm_cfft_q15(&arm_cfft_sR_q15_len256, buf, 0, 1);
arm_cmplx_mag_q15(buf,Real,FFT_size);
}
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_I2S1_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_I2S_Receive(&hi2s1, buf, FFT_size, 1);
FFT_compute();
}
/* USER CODE END 3 */
}
2024-11-08 10:15 AM - edited 2024-11-08 11:55 AM
Linker errors occur because you don't add the library or it's source to the project.
An INCLUDE file typically does add code, it provides the inferface details, the code behind the library still needs to be accessible to the LINKER
2024-11-08 10:33 AM
Can you please share a method to correctly include as I have tried many different ways but I get the same error
2024-11-08 11:59 AM
I'm not using your tools. But standard compiler/linker methods dictate
Step#1 include paths for tools, and add #include in your source
Step#2 Add the library .a file if prebuilt so the linker knows where the function bodies live, or add library source files to your project directly so the compiler compiles them.