cancel
Showing results for 
Search instead for 
Did you mean: 

Stack size in Cosmic

krzysztof239955_st
Associate II
Posted on October 07, 2009 at 05:45

Stack size in Cosmic

3 REPLIES 3
krzysztof239955_st
Associate II
Posted on May 17, 2011 at 15:05

Hi,

I use recursive function qsort.

How can increase the size of the stack?

I use Cosmic compiler with Stack Long (modsl0) memory model.

Regards,

krzysztof.skoczek

luca239955_st
Associate III
Posted on May 17, 2011 at 15:05

Hello,

there's no need to increase the stack size, as this is not a parameter you can control (at least directly) in your source files or application settings.

In a typical stm8 application, the stack is initialized at the highest ram address and then grows backwards: if it grows too much, one of the two things below will happen, both leading to unpredictable system behaviour (crash!):

- the stack will overwrite some other memory area (probably global variables)

- the stack pointer will wrap around to its original value (hardware limitation)

Regards,

Luca (Cosmic)

Posted on July 19, 2017 at 23:58

I don't know if it helps your issue, but your question has 'recursive' and 'size of the stack' - and that really helped me a lot thanks!. 

Im running FreeRTOS on STM32F1 series. 

I also have a recursive function. Mine has programmed limits on its depth, but it was still causing the HardFault_Handler to execute. 

I fixed it by increasing the stack size on the FreeRTOS thread. In this case form 128 to 256. 

osThreadDef(Handle, StartHandler, osPriorityBelowNormal, 0, 256);

I was able to make the setting the the CubeMx configuration as well. 

Thanks again!