Skip to main content
Crane
Associate II
Aug 26, 2022 1:26 AM UTC
Solved

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

..

This topic has been closed for replies.
TThan
TThanBest answer
Associate III
Aug 26, 2022 7:40 AM UTC

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
Aug 26, 2022 7:40 AM UTC

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
Aug 27, 2022 4:09 AM UTC

Got it. Thanks a lot Tthan!