CMSIS with CubeMx

Share code examples or discuss embedded software, including device drivers, interrupt handlers, middleware and application code.

Moderators: Markus Girdland, Mattias Norlander

Posts: 2
Joined: Sun Oct 02, 2016 6:01 pm

CMSIS with CubeMx

Postby gwolfsystems » Sat Jan 28, 2017 11:53 pm

Hi, I've been working with Atollic truestudio and CubeMx to make projects with STM32. I recently started working with CMSIS DSP, I have to build some digital filters. My problem is that when I make a project with CubeMx, I can't use the functions from arm_math.h. Every time I put a function declared from this header, I get the error "undefined reference to..." I don't know what to do>. I attach you the beggining of my code, when I'm trying to inicialize a instance of a cfft I get this error. Can somebody help me? Thanks!

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32f4xx_hal.h"

/* Private variables ---------------------------------------------------------*/
#define SAMPLES 512 /* 256 real party and 256 imaginary parts */
#define FFT_SIZE SAMPLES / 2 /* FFT size is always the same size as we have samples, so 256 in our case */
#define ARM_MATH_CM4

#include "arm_math.h"

/* Global variables */
float32_t Input[SAMPLES];
float32_t Output[FFT_SIZE];
/* Private variables ---------------------------------------------------------*/

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
void Error_Handler(void);
static void MX_GPIO_Init(void);

/* Private function prototypes -----------------------------------------------*/

int main(void)
arm_cfft_radix4_instance_f32 S; /* ARM CFFT module */
/* MCU Configuration----------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */

/* Configure the system clock */

/* Initialize all configured peripherals */

/* Initialize the CFFT/CIFFT module, intFlag = 0, doBitReverse = 1 */
arm_cfft_radix4_init_f32(&S, FFT_SIZE, 0, 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);

/* Calculates maxValue and returns corresponding value */
//arm_max_f32(Output, FFT_SIZE, &maxValue, &maxIndex);

/* Infinite loop */
while (1)



Mattias Norlander
Posts: 265
Joined: Fri Apr 29, 2016 10:01 am

Re: CMSIS with CubeMx

Postby Mattias Norlander » Wed Feb 01, 2017 7:27 am

Have you solved it?

"Undefined reference to" indicates that the toolchain cannot find the source file / library containing function body.
Looking into the Cube packages it seems to be distributed as source code.
Is the source code being setup as a source code folder in TrueSTUDIO?
Perhaps only the includes are setup correctly but the c-files are not visiible to the toolchain?

Posts: 94
Joined: Wed Apr 05, 2017 5:08 pm
Location: USA

Re: CMSIS with CubeMx

Postby frank_ee » Mon Jul 31, 2017 6:21 pm


I have used the CMSIS DSP libraries, you have to make sure all function calls have their function definitions visible by having their files built into the project. For example, the code for the example DSP operations, I added the required C files to the project to save space.

Posts: 5
Joined: Tue Aug 23, 2016 5:34 pm

Re: CMSIS with CubeMx

Postby SNM60 » Sat Oct 06, 2018 4:59 pm

Hi I do have the same problem; did you solve it? Cheers Stefan

Mattias Norlander
Posts: 265
Joined: Fri Apr 29, 2016 10:01 am

Re: CMSIS with CubeMx

Postby Mattias Norlander » Mon Oct 08, 2018 9:01 am

In TrueSTUDIO go into the Project Properties --> C/C++ General --> Paths and Symbols --> Source Location.
Here you can see which source-folders that are on the build path.
Look into these folders. Do they include the source code for the DSP functions? If not - then there is your issue, the source files are not visible to the compiler.

Posts: 2
Joined: Sun Oct 02, 2016 6:01 pm

Re: CMSIS with CubeMx

Postby gwolfsystems » Thu Oct 18, 2018 5:20 pm

Hello guys, It's been a while since I worked on this project. As CMSIS reference says, you have to add a pre-built library in order to work with DSP functions. See I was working with STM32F4 so I had 4 libraries to choose. The choise depends of whether you use fixed point or floating point variables and if you use little or big endian variables. see ... s15_3.html

Return to “Embedded target code development discussions”

Who is online

Users browsing this forum: No registered users and 1 guest