AnsweredAssumed Answered

STM32CubeMX FreeRTOS and Queue Sizes (Bug)

Question asked by Jive Tihs on Sep 13, 2017
Latest reply on Feb 1, 2018 by Jeanne Joly

STM32CubeMX allows to enter either a type (i.e. uint16_t) or a decimal (i.e. 50) in the "Item Size" edit box when defining a Queue and correctly calculates the overall size in the GUI. However, when using a decimal, the generated code isn't correct. Here is the part of a generated code when using 50 as "Item Size" and 4 as "Queue Size":

 

osMessageQId my_queueHandle;
uint8_t my_queue_buffer[ 4 * sizeof( 50 ) ];
osStaticMessageQDef_t my_queue_control;

sizeof ( 50 ) is 4 in STM32. The correct code is:

osMessageQId my_queueHandle;
uint8_t my_queue_buffer[ 4 * 50 ];
osStaticMessageQDef_t my_queue_control;

 

As a suggestion, STM32CubeMX's FreeRTOS configuration window has a "User Constants" tab where we can enter constant definitions. It would be very nice if we could use those defined constants too when entering the queue (or other) sizes too. We will end up with something like this which is way better:

 

osMessageQId my_queueHandle;
uint8_t my_queue_buffer[ MY_QUEUE_SIZE * MY_QUEUE_ITEM_SIZE ];
osStaticMessageQDef_t my_queue_control;

Outcomes