Skip to main content
Crane
Associate II
August 26, 2022
Solved

I am using STM32CubeMX to config FreeRTOS. I couldn't find where to define configASSERT(). Can anyone help with this?

  • August 26, 2022
  • 2 replies
  • 1419 views

..

This topic has been closed for replies.
Best answer by TThan

Hi Crane,

when you generate a project with STM32CubeMX that uses FreeRTOS the definition of the configASSERT() macro is placed in between "USER_CODE" comments in the generated Inc/FreeRTOSConfig.h file:

/* USER CODE BEGIN 1 */
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
/* USER CODE END 1 */

That is a strong hint that this definition is not managed by STM32CubeMX but may and can be changed by the user.

So simply change the definition later in the generated file. It will not be overwritten on later re-generations since it is protected by the "USER_CODE_..." comments.

Regards

Thomas

2 replies

TThan
TThanBest answer
Associate III
August 26, 2022

Hi Crane,

when you generate a project with STM32CubeMX that uses FreeRTOS the definition of the configASSERT() macro is placed in between "USER_CODE" comments in the generated Inc/FreeRTOSConfig.h file:

/* USER CODE BEGIN 1 */
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
/* USER CODE END 1 */

That is a strong hint that this definition is not managed by STM32CubeMX but may and can be changed by the user.

So simply change the definition later in the generated file. It will not be overwritten on later re-generations since it is protected by the "USER_CODE_..." comments.

Regards

Thomas

Crane
CraneAuthor
Associate II
August 27, 2022

Got it. Thanks a lot Tthan!