<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>CodeWarrior for MCU中的主题 Re: What should the stack size be for my application?</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142166#M2811</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Why not? It is simple enough to check how much you are using. And you could for example set stack size to be RAM size minus the size of the globals. The latter can be found in the .map file.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Jan 2007 19:49:06 GMT</pubDate>
    <dc:creator>Lundin</dc:creator>
    <dc:date>2007-01-09T19:49:06Z</dc:date>
    <item>
      <title>What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142159#M2804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm come here from pic world and new at freescale.&lt;/DIV&gt;&lt;DIV&gt;How&amp;nbsp;can I indicate stack size that my application needs?&lt;/DIV&gt;&lt;DIV&gt;My application start exhibiting some interesting behaviours and I'm doubting that it needs more stack. But I don't know what it exactly should be.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Here is my actual prm file.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;SEGMENTS&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp; READ_ONLY&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x1870 TO 0xFFAF;&amp;nbsp;&amp;nbsp;&amp;nbsp; Z_RAM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp; READ_WRITE&amp;nbsp;&amp;nbsp; 0x0060 TO 0x00FF;&amp;nbsp;&amp;nbsp;&amp;nbsp; RAM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp; READ_WRITE&amp;nbsp;&amp;nbsp; 0x0100 TO 0x0C5F;&amp;nbsp;&amp;nbsp;&amp;nbsp; NO_INIT_RAM_SEG&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp; NO_INIT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x0C60 TO 0x105F;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROM1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp; READ_ONLY&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x1060 TO 0x17FF;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROM2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp; READ_ONLY&amp;nbsp;&amp;nbsp;&amp;nbsp; 0xFFC0 TO 0xFFD1;ENDPLACEMENT&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEFAULT_RAM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO&amp;nbsp; RAM;&amp;nbsp;&amp;nbsp;&amp;nbsp; NO_INIT_RAM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO&amp;nbsp; NO_INIT_RAM_SEG;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEFAULT_ROM, ROM_VAR, STRINGS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO&amp;nbsp; ROM;&amp;nbsp;&amp;nbsp;&amp;nbsp; _DATA_ZEROPAGE, MY_ZEROPAGE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO&amp;nbsp; Z_RAM;ENDSTACKSIZE 0x50&lt;/PRE&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:42:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142159#M2804</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2020-10-29T08:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142160#M2805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;My application is for MC9S08LC60. I changed the stack size&amp;nbsp;with 0x200. It seems working well for now. I still wonder if there is a way to detect stack overflow condition for the future?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Here is my new prm file:&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;/* This is a linker parameter file for the mc9s08lc60 */NAMES END SEGMENTS         Z_RAM                    =  READ_WRITE   0x0060 TO 0x00FF;  // 160 byte    RAM                      =  READ_WRITE   0x0100 TO 0x0A5F;  // 2400 byte    NO_INIT_RAM_SEG          =  NO_INIT      0x0A60 TO 0x0E5F;  // 1024 byte    MY_STK                   =  NO_INIT      0x0E60 TO 0x105F;  // 512 byte    ROM1                     =  READ_ONLY    0x1060 TO 0x17FF;    ROM                      =  READ_ONLY    0x1870 TO 0xFFAF;    ROM2                     =  READ_ONLY    0xFFC0 TO 0xFFD1;ENDPLACEMENT     _DATA_ZEROPAGE, MY_ZEROPAGE         INTO  Z_RAM;    DEFAULT_RAM                         INTO  RAM;    NO_INIT_RAM                         INTO  NO_INIT_RAM_SEG;    SSTACK                              INTO  MY_STK;    DEFAULT_ROM, ROM_VAR, STRINGS       INTO  ROM;         ENDSTACKSIZE 0x200VECTOR 0 _Startup&lt;/PRE&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:42:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142160#M2805</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2020-10-29T08:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142161#M2806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;You do it the same way on any micro. Start the debugger, set the whole stack segment to zero, let the program run for a while. Then check how much of it that is still zero.&lt;BR /&gt;&lt;BR /&gt;A more serious approach would be to record the SP through for example an emulator, but that is probably overkill for most apps. Perhaps there are some debuggers that support this, but Codewarrior doesn't.&lt;BR /&gt;&lt;BR /&gt;Another method you can use on some Freescale micros is to map the stack just above a segment that isn't used, then run the program for a while. If the stack tries to write to the memory area that isn't used, you will get "software interrupt" or similiar.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jan 2007 22:51:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142161#M2806</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2007-01-08T22:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142162#M2807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I have found a compiler parameter "-Ll: Statistics about Each Function" , but it gives stack size at only function level. I saw that this kind of stack usage&amp;nbsp;is very dangerous and hard to debug for my application.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Is there any way to tell compiler not to use stack area for local variables? For example, hitech picc18&amp;nbsp;doesn't use pic's limited stack area for local variables. Instead of that, It automatically allocates global ram&amp;nbsp;area for them and optimizes&amp;nbsp;their size according to call-graph of functions and their local ram requirements. You only care nested&amp;nbsp; called function counts. I think this way is more programmer friendly.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Do you know codewarrior support this?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jan 2007 02:59:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142162#M2807</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2007-01-09T02:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142163#M2808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Since C is so very focused at stack usage, it is probably wise to keep as much locals as possible on the stack, if you have enough RAM for it.&lt;BR /&gt;&lt;BR /&gt;In ANSI C, you allocate variables with the keyword "static" to prevent them from ending up on the stack. Global variables will not be placed on the stack either. If you wish to place a global variable at a certain location, use the Codewarrior #pragma DATA_SEG.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jan 2007 15:23:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142163#M2808</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2007-01-09T15:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142164#M2809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Of course, defining variables as static or global will "dedicate" ram locations to those variables, so it will use more ram than if they "shared" space on the stack.&lt;BR /&gt;&lt;BR /&gt;So having automatic variables on the stack is a form of optimizing for ram space.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jan 2007 17:06:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142164#M2809</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2007-01-09T17:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142165#M2810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I don't want to use local variables&amp;nbsp;in stack&amp;nbsp;unless the compiler automatically control&amp;nbsp;stack size. Instead of that, the compiler should reserve a shared area globally for them and optimize size of the area itself. Does the compiler do this automatically?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;What is the "OVERLAP" segment and How&amp;nbsp;does it work? Can I use it for this purposes?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jan 2007 18:00:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142165#M2810</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2007-01-09T18:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142166#M2811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Why not? It is simple enough to check how much you are using. And you could for example set stack size to be RAM size minus the size of the globals. The latter can be found in the .map file.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jan 2007 19:49:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142166#M2811</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2007-01-09T19:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142167#M2812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;Lundin wrote:&lt;BR /&gt;Why not? It is simple enough to check how much you are using. And you could for example set stack size to be RAM size minus the size of the globals. The latter can be found in the .map file.&lt;BR /&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;Actually the problem exactly is this. The compiler doesn't&amp;nbsp;tell me how much stack my application is using. I can't calculate manually this value by using function call-graph. The compiler should do this automatically for me. Even I allocate whole empty ram space for stack, the application may need more. We can't know this. So I personally don't preffer this method unless the compiler checks it.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jan 2007 23:17:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142167#M2812</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2007-01-09T23:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142168#M2813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, BasePointer:&lt;BLOCKQUOTE&gt;&lt;HR /&gt;BasePointer wrote:&lt;BR /&gt;The compiler doesn't tell me how much stack my application is using.&lt;BR /&gt;&lt;BR /&gt;We can't know this . . .&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;There is no way for the compiler to know how much stack space you need. The compiler doesn't know how your firmware is meant to behave, and it can't know ahead of time what conditions will cause a function to be called.&lt;BR /&gt;&lt;BR /&gt;A simplified example is a recursive subroutine. I have one routine that converts a 16-bit integer to an ascii string. It recursively calls itself for each ascii digit in the number. The compiler will never know that the function will nest a maximum of 5 times (5 digits for a 16-bit number) so it can never tell you how much stack is necessary. Only I know that. As far as it can tell at compile time, it might need an infinite amount of stack.&lt;BR /&gt;&lt;BR /&gt;Only you can calculate worst case stack usage. I have had to do this on a few projects, and a call tree helps a lot. It can be time consuming, but in those cases I would charge by the hour.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jan 2007 05:45:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142168#M2813</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2007-01-10T05:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142169#M2814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi&lt;BR /&gt;&lt;BR /&gt;Memory usage is a rather critical point in small footprint devices. The uTasker project uses also a run time stack (and heap) monitor.&lt;BR /&gt;&lt;BR /&gt;I have an NE64 project running on line here: &lt;A href="http://84.253.57.46/" rel="nofollow" target="_blank"&gt;Online NE64&lt;/A&gt;.&lt;BR /&gt;If you go to the "administration page" of its embedded web server you see the present heap and stack usage figures as well as the length of time the demo has been running for. The stack value is the "safety margin" and represents the amount of SRAM between the heap (which is positionen on top of the fixed variables) and the lowest point the stack pointer has reached.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Mark Butcher&lt;BR /&gt;&lt;A href="http://www.uTasker.com" rel="nofollow" target="_blank"&gt;www.uTasker.com&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jan 2007 10:49:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142169#M2814</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2007-01-10T10:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142170#M2815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I didn't say you should use the function call graph, I said that you should check how much of the RAM that is used by globals and statics which can be found in the .map file.&lt;BR /&gt;&lt;BR /&gt;I assume that you intend to use your whole RAM. Then you can set your stack size according to:&lt;BR /&gt;&lt;BR /&gt;RAM_size - globals_size = stack_size.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Further, keeping track of the stack size is the programmer's responsibility. Unless your system is totally deterministic, with no I/O or interrupts what-so-ever, then the compiler CAN'T know the stack size. For example, how exactly do you expect the compiler to calculate how many nested interrupts that your program will receive? How can the compiler know if a certain function will be called or not if the condition for calling the function depends on a run-time variable, like a port register?&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jan 2007 16:35:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142170#M2815</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2007-01-10T16:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142171#M2816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello all,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I totally agree that the compiler cannot know the stack size required.&amp;nbsp; However, I would argue that the debugger should be aware, at least in full chip simulation mode.&amp;nbsp; Since the stack pointer is being simulated, I might have expected the debugger to issue a warning in the event that the allocated stack size is exceeded during the simulation process.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The 8-bit debugger does not appear to provide any warnings of this nature.&amp;nbsp; I have had instances where global variables residing immediately underneath the allocated stack have been over-written by the stack - without any warning being issued.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Perhaps it&amp;nbsp;would also not be unreasonable to expect the debugger&amp;nbsp;to keep track of the lowest stack pointer value achieved during simulation.&amp;nbsp; But this is&amp;nbsp;probably wishful thinking.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jan 2007 21:26:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142171#M2816</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-01-10T21:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142172#M2817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;All the problem here is local variables stored in stack. Stack area&amp;nbsp;is mostly consumed by local variables for applications.&amp;nbsp;Not recursive functions nor nested interrupts. Of course the compiler exactly can't know count of recursive functions or nested interrupts or called functions via function pointers. These are exceptions, I think.&amp;nbsp;But it can simply calculate total stack size of main function according to functions call-graph by summing stack size necessary&amp;nbsp;for the&amp;nbsp;each functions. I'm doing this manually&amp;nbsp;and the compiler&amp;nbsp;can do&amp;nbsp;this automatically. This value will be the *minimum stack* necessary that the programmers must be aware of. This does not mean it will be enough. If you use recursive functions or nested interrupts, of course, you must grow up the minimal stack size calculated by the compiler according to your application, the compiler can't know or simulate when your this kind of algorithms stop in real.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jan 2007 02:06:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142172#M2817</guid>
      <dc:creator>BasePointer</dc:creator>
      <dc:date>2007-01-11T02:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142173#M2818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, BasePointer:&lt;BR /&gt;&lt;BR /&gt;Keep in mind, however, that local variables on the stack only exist while the function is executing. They are destroyed, and their stack space is recovered, once the function returns. So summing the stack size for each function may give you an overly large result.&lt;BR /&gt;&lt;BR /&gt;But if there is no nesting taking place, it can be considered a valid worst-case size. Though you should probably add five for simple interrupts.&lt;BR /&gt;&lt;BR /&gt;And I agree with Mac:&lt;BR /&gt;There is no reason that the debugger and simulator could not monitor the stack pointer and flag a stack overflow/underflow. I consider this a very basic debugging function, that should have been there from day one.&lt;BR /&gt;&lt;BR /&gt;While I an debugging, I put the stack in a memory window so I can keep an eye on it.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jan 2007 03:17:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142173#M2818</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2007-01-11T03:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142174#M2819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;The HC12 Simulator actually has a command to ask for the range the SP had in the past. Enter "STACK_POINTER_INFO INFO" on the command line to get the values, "STACK_POINTER_INFO ?" to see all the subcommands (like reset the info).&lt;BR /&gt;Also the command STACK_AREA_CHECK can be used to enable some stack range checking, so the simulator stops once SP is outside. "STACK_AREA_CHECK ?" shows the commands,&lt;BR /&gt;"STACK_AREA_CHECK AUTO" takes the stack area out of the elf file,&lt;BR /&gt;"STACK_AREA_CHECK ON 0x1000..0x1FFF" uses the given range instead.&lt;BR /&gt;&lt;BR /&gt;This commands are available in the HC12/HCS12/HCS12X simulator only, not with the HC08/HCS08/RS08 :smileysad:.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jan 2007 06:06:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142174#M2819</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2007-01-12T06:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142175#M2820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;About the automatic stack size computation.&lt;BR /&gt;This is really THE feature I miss most. I really suggested this many times in the past.&lt;BR /&gt;The computation has to be done with the call graph in mind, so not actually in the compiler, but in the linker. The compiler should be extended to provide more accurate information about the function tough. Its not just adding the frames of all functions, its really computing a pessimistic max stack size considering a static call graph.&lt;BR /&gt;In general there are case where this is not doable completely, like with function pointers, recursion, assembly code, inline assembly code. Interupts are not that hard though as they just can be considered with a separate call graph.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jan 2007 06:20:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142175#M2820</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2007-01-12T06:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142176#M2821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;The competition has been doing it for years!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The Cosmic linker analyzes the call graph and outputs the maximum stack usage for each function, including all called functions.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Of course, it doesn't work for recursive functions.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is relatively easy for them.&amp;nbsp;The linker is already aware of the call graph because they have an&amp;nbsp;option&amp;nbsp;to optimize storage of locals in a shared fixed RAM area rather than on the stack.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Jan 2007 05:43:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142176#M2821</guid>
      <dc:creator>StephenRussell</dc:creator>
      <dc:date>2007-01-13T05:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142177#M2822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I didn't originate this thread,but it interests be nonetheless. I am also new to&lt;BR /&gt;this micro. I am more familiar with the TI 16 bit DSP micros where I typically do what you suggest and map the stack in memory so that a stack overflow will attempt to write to an illegal address. On the TI architecture this asserts an NMI which I use to report debugging info.&lt;BR /&gt;&lt;BR /&gt;Could you be more specific about how this might work on the freescale micro, or point me to the proper documentation. I've gone through the documentation and have not located any section where it mentions what happens when you attempt to read from an illegal address. All I see is the interrupt for "Illegal Opcode" (also quite useful).&lt;BR /&gt;&lt;BR /&gt;I am more than happy to RTFM if someone can point me at the correct one ;^).&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Igor&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Jan 2007 02:05:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142177#M2822</guid>
      <dc:creator>igorstravinsky</dc:creator>
      <dc:date>2007-01-14T02:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: What should the stack size be for my application?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142178#M2823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello Igor,&lt;BR /&gt;&lt;BR /&gt;It depends on the architectures.&lt;BR /&gt;On Freescale MCUs = HC08, S08, HC12, S12 and S12XD, there isn't any Illegal memory read.&lt;BR /&gt;Reading from reserved or un-implemented locations will return garbage.&lt;BR /&gt;&lt;BR /&gt;On the S12XE, you can declare descriptors to protect different areas of memory from read and/or write.&lt;BR /&gt;&lt;BR /&gt;On 32-Bit MCU, DSP and everything else, I have no clue.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Alban.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Jan 2007 02:13:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/What-should-the-stack-size-be-for-my-application/m-p/142178#M2823</guid>
      <dc:creator>Alban</dc:creator>
      <dc:date>2007-01-14T02:13:42Z</dc:date>
    </item>
  </channel>
</rss>

