cancel
Showing results for 
Search instead for 
Did you mean: 

STMCube IDE problems with Queues

tarmogr
Associate II

Im creating an RTOS queue in the configuration tool. Whowever if I try to place anything in the queue the program crashes.

Configuration:

tarmogr_1-1715164215219.png

 

Generated Initialization

tarmogr_2-1715164240241.pngtarmogr_3-1715164262270.png

 

Place item in queue (btn.dec is a uint8_t variable)

tarmogr_4-1715164307685.png

 

Debug

tarmogr_0-1715164179092.png

 

As you can see the item size is wrong, although the two queues are created equal.

 

What could cause this?

 

7 REPLIES 7
Sarra.S
ST Employee

Hello @tarmogr

Ensure that the data you're sending (btn.dec) is indeed a uint8_t. If btn.dec is not a single byte, this could be the source of the problem.

Also, check in the queue creation, that the item size parameter (sizeof(uint8_t)) matches the actual size of the items you will place in the queue.

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.

Thank you Sarra for your reply. Just to remove any doubts I defined a new uint8_t variable which i am sending to the queue. For me this does not seem to be an issue. Any more ideas?

tarmogr_0-1715168936812.png

 

And also one interesting thing to note. My MCU only seems to crash while in debug mode. When I run it normaly it runs fine or at least not often enough to notice immediately.

Use the debugger to check the fault registers and stack frame to determine the source of the fault.

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.

tarmogr
Associate II

So I was checking the heap size of my FreeRTOS task. There is this "chargerTask". I know that I dynamically allocate about 431 bytes in it. The settings in configuration was as follows:

tarmogr_1-1715240510703.png

 

tarmogr_0-1715240492875.png

I can only edit "stack size" on the first image. which is in words. In bytes it is then 512 bytes. According to my understanding it is enough for my dynamic memory, or am i wrong?

Anyway after increasing the stack size to 1024 the problem does not occur anymore.

What would be the correct way of calculating heap/stack size here?

Sarra.S
ST Employee

Hello @tarmogr

Please check Heap memory management  

Typically, you would implement a stack overflow detection mechanism by using the configCHECK_FOR_STACK_OVERFLOW configuration constant in your FreeRTOSConfig.h file, also check  Stack usage and Stack Overflow Checking

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.

It seems there were indeed some heap size problem. However a problem with one of the queues still persist. In debug view it shows some randomly high number as an item size. Both queues are created by configuration tool. Any idea what could cause this?

tarmogr_0-1716892668445.png

in main.c:

tarmogr_1-1716892716284.png