2016-03-03 12:22 AM
Hi all,
Thanks in advance for your time spent on this topic.I have spent several months on STM32 project, fine with software coding, but keep confusion on the startup file, which would appear inalmost every project as below. I think everyone of you also should be very familiar with it. I have spent time reading this code. It is like, I can understand every part of the code itself from grammar, but know nothing on big picture.For example, I know it is the first code would be run after power on,it setup the stack, heap, interrupt entry address,and then load main() function.However, is there anything that I can play with it? Such as the stack and heap setup code below:------------------------------------------------------------------------------------------------; Amount of memory (in bytes) allocated for Stack; Tailor this value to your application needs; <h> Stack Configuration; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>; </h>Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE, ALIGN=3Stack_Mem SPACE Stack_Size__initial_sp ; <h> Heap Configuration; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>; </h>Heap_Size EQU 0x00000200 AREA HEAP, NOINIT, READWRITE, ALIGN=3__heap_baseHeap_Mem SPACE Heap_Size__heap_limit--------------------------------------------------------------------------------------------------The code above set stack size to 0x00000400, heap size to 0x00000200, but why? Can I change it? Based on what criteria?Is this .s code specified to MCU core or board level? Do I need to modify the code if I design a different board with different peripherals but with same MCU?In other words, When, and how, must I make modifications to this .s startup file?Thanks~~ #startup-file
2016-03-03 08:56 AM
Hi lao.jian,
You may find more explanation on the startup file content in https://www.keil.com/pack/doc/CMSIS/Core/html/startup_s_pg.html.-Mayla-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.
2016-03-03 10:30 AM
Do your subroutines use local/auto variables? How do those stack up for your deepest call chain? The default stack is often inadequate, especially when used with sscanf/sprintf type functionality. It also often catches PC coders used to huge limitless stacks, and not aware of static or const directives and there appropriate use in subroutines.
Do you malloc any variables or allocations during initialization, or run time? Is the heap provided adequate to support your needs?If you can answer these questions, then you should be able to determine *your* heap/stack requirements.