mustafabarakat
mustafabarakat

Reputation: 419

STM32 - RTOS - Max Stack Size

I'm using STM32F103R8T6 with RTOS with 2 threads

osThreadDef(ManagerTask, ManagerThread, osPriorityNormal, 0, 128);
  ManagerTaskHandle = osThreadCreate(osThread(ManagerTask), NULL);
  osThreadDef(RFIDTask, RFIDThread, osPriorityNormal, 0, 256);
  RFIDTaskHandle = osThreadCreate(osThread(RFIDTask), NULL);

when i try to give the any thread a stack size of >512, neither of the tasks run, but when using 128 and 256 as the above example everything is fine.

So how to i know the max total stack size that i can allocate for my threads ?

in my RTOS Config

#define configMINIMAL_STACK_SIZE                 ((uint16_t)128)
#define configTOTAL_HEAP_SIZE                    ((size_t)3072)

Upvotes: 1

Views: 5327

Answers (1)

denis krasutski
denis krasutski

Reputation: 637

If you use FreeRTOS keep in the mind that stack size value in words not in bytes! But configTOTAL_HEAP_SIZE in bytes!

In this conditions:

  • TaskA 512 words = 2048b
  • TaskB 128 words = 512b
  • Totaly have = 2560b

Almost 3072 :) so if you don't use other objects it will work but if you some increase stack or will use additional objects the heap will be depleted

Source: https://www.freertos.org/a00125.html

Upvotes: 1

Related Questions