2016-02-03 03:16 PM
2016-02-04 09:31 AM
Hi lopez.dean,
Thanks for your feedback and contribution.
“Hi, I am trying to find a description or guidelines for how CubeMX determines the TOTAL_HEAP_SIZE value under the FreeRTOS Config parameters. I am using the Heap 4 scheme.�
In a coming version of CubeMx, TOTAL_HEAP_SIZE will automatically calculated to optimize and adjust application.
“
However, that leads me to want to know how can I determine, after FreeRTOS has loaded and allocated enough RAM for it's needs, what is left over for the heap space that will be consumed when I spawn threads w/ stacks, and create queues and semaphores.�
The total amount of available heap space is set by configTOTAL_HEAP_SIZE which is defined in FreeRTOSConfig.h.
The xPortGetFreeHeapSize() API function returns the total amount of heap space that remains unallocated (allowing the configTOTAL_HEAP_SIZE setting to be optimized).
The total amount of heap space that remains unallocated is also available with xFreeBytesRemaining variable for heap management schemes 2 to 5.
configMINIMAL_STACK_SIZE defines the minimum stack size that can be used in words. the idle task stack size takes automatically this value.
Optimize stack allocation for each task :
uxTaskGetStackHighWaterMark() . This API returns the minimum number of free bytes (ever encountered) in the task stack
vApplicationStackOverflowHook(). This API is a stack overflow callback called when a stack overflow is detected (available when activating the define configCHECK_FOR_STACK_OVERFLOW)
Adjust heap dimensioning :
xPortGetFreeHeapSize(). API that returns the total amount of heap space that remains unallocated. Must be used after created all tasks, message queues, semaphores, mutextes in order to check the heap consumption and eventually re-adjust the application define � configTOTAL_HEAP_SIZE�.
The total amount of heap space that remains unallocated is also available with xFreeBytesRemaining variable for heap management schemes 2 to 5
You can refer ,also, to the User manual
''Developing Applications on STM32Cube with RTOS'' > section FreeRTOS memory managemant.Hope these information help you in your FreeRTOS based project .
-Hannibal-
2016-02-04 11:54 AM