cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX Custom Queue Sizes in FreeRTOS

eweststrate
Visitor

I am having trouble creating custom queue sizes and making them work with the Heap Usage tool within CubeMX.  But I found a workaround until the bug gets fixed.

I created a queue using a custom item size (the message_data_t type is defined in my code):

eweststrate_0-1738710049448.png

The code generation is correct:

  /* Create the queue(s) */
  /* creation of UsbRxQueue */
  UsbRxQueueHandle = osMessageQueueNew (16, sizeof(message_data_t), &UsbRxQueue_attributes);

  /* creation of BufferQueue */
  BufferQueueHandle = osMessageQueueNew (8, sizeof(message_data_t), &BufferQueue_attributes);

  /* creation of SystemQueue */
  SystemQueueHandle = osMessageQueueNew (16, sizeof(message_data_t), &SystemQueue_attributes);

 

When the Heap Usage tool calculates the memory the queue needs, it incorrectly uses 4 bytes by default the heap size is wrong.

eweststrate_1-1738710182293.png

My solution is to create a user constant to tell the GUI what size it is:

eweststrate_2-1738710291653.png

.. then I #undef the message_data_t it creates so the code compiles correctly!

/* Private defines -----------------------------------------------------------*/
#define GAIN_COMP1 0
#define GAIN_COMP2 0
#define message_data_t 8
#define USART2_TX_Pin GPIO_PIN_2
#define USART2_TX_GPIO_Port GPIOA
....

/* USER CODE BEGIN Private defines */

// CubeMX bugfix:
#undef message_data_t

I think it works, but will post any updates.

0 REPLIES 0