3 Replies Latest reply on Nov 27, 2011 11:59 PM by udayanu_

    stack/heap usage of PSoC5



      We are developing a  project using PSoC, The project is nearly finished, but we would like know if we can use a bit more RAM for some furture expansion. We sould also like to know how much RAM is being used for stack and heap, (I mean it is ACTUALLY used, not being assigned for ). Any one has any idea how we can get the information.  I have this post to Cypress support already, hope some one has done this before. 


      I know there are programs to trace stack usage but not sure it is aviable for PSOoC5 or G++ lite for ARM devices.


      There is another way which is to fill the stack area with a spcial pattern and let the program run and excersise the possible combination and then check the pattern again -( this is not as good as the first one, but at least give some indication of usage.) I am reading the CodeSourcery manual and would like to know if some one has the experience to modify the startup code to do this



        • 1. Re: stack/heap usage of PSoC5
          • The default for a PSoC 5 project is the stack size = 16K (0x4000) and the heap size to be 4K (0x1000).  These are settable parameters, in the .cydwr file, System tab, Configuration node.
          • In order to see the allocation of stack and heap look in to the .map file. In the .map file you can see that the stack space is located at the top of SRAM (the stack/SP/R13 grows downward), and the heap space is located under the stack space. The amount of SRAM being used for the stack at any particular time is just the top of SRAM address minus the value in R13.
          • Don't forget that the Cortex-M3 has two stack pointers, both sharing the R13 space - check PSoC 5 datasheet Table 4-2 for details. In most simple projects only the main stack pointer (MSP) is used.



          • 2. Re: stack/heap usage of PSoC5


                1.& 2 : I have no problem changing the size and location the address of the stack and heap from the map file.   
                3. I don’t want to access the SP directly unless needed to. Just wondering if anyone has done this before or Cypress already have tools to do this.   
            • 3. Re: stack/heap usage of PSoC5

              The Stack Pointer value changes dynamically in the run time depending on how your code is structured. Could you tell us what kind of tool you are expecting ?