Skip to main content
Mike xx
Associate III
February 14, 2023
Solved

Issues with FreeRTOS queue and changing "Queue Size" and "msg_size"

  • February 14, 2023
  • 2 replies
  • 3065 views

There are times where I would like a message queue of a single depth. In some similar OSes this is also how semaphores are created. I have hit a near brick wall in STM32CubeMX failing to create a queue with just one element.

In this case for the STM32F4 library, I get the following call where I set a "Queue Size" 1 in:

Middleware -> FreeROTS -> Tasks and Queues -> Queues -> Queue Size.

This creates a function:

I2CWriteQHandle = osMessageQueueNew (2, sizeof(i2c_data_type), &I2CWriteQ_attributes);

Note the "msg_count" argument is 2, despite all the I2CWriteQ_attributes being consistent with those being set in ST32CubeMX. If the queue is increased to say 16, msg_count remains at 2. Other queues with a osMessageQueueNew "msg_count" set at 16, remain at 16.

If I manually correct the "msg_count" argument, the new value is retained when (re)generating the code.

I presume this behaviour of unlinking "Queue Size" "msg_count" is unintened and not sure when this issue started. BTW I am using v6.7.1 and have applied the patch associated with this version.

This topic has been closed for replies.
Best answer by Mike xx

I apologise for not replying earlier.

Soon after getting this issue I upgraded the CubeMX applications.

What I can say is that I can't reproduce the problem with STM32CubeMX v6.8.0

I've change the queue size and the corresponding numbers ("Queue Size" "msg_count") in freertos.c change as one might expect and the project compiles fine.

2 replies

Semer CHERNI
ST Employee
February 23, 2023

Hello @Community member​ 

Frist let me thank you for posting.

I have an issue reproducing the described behavior.

I am using the following setup:

  • STM32CubeMx 6.7 with the patch applied
  • STM32CubeIDE 1.11.2
  • Windows 10
  • STM32F439 MCU

Down bellow screenshots from the CubeMx setting and the generated code:

0693W00000aHVCLQA4.png0693W00000aHV9XQAW.pngCould you provide a project where the issue is reproduced or at least an *.ioc file.

Kind regards,

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Mike xx
Mike xxAuthorBest answer
Associate III
March 14, 2023

I apologise for not replying earlier.

Soon after getting this issue I upgraded the CubeMX applications.

What I can say is that I can't reproduce the problem with STM32CubeMX v6.8.0

I've change the queue size and the corresponding numbers ("Queue Size" "msg_count") in freertos.c change as one might expect and the project compiles fine.