<?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中的主题 Stack usage (CWS-H12-PRO v. 4.5)</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Stack-usage-CWS-H12-PRO-v-4-5/m-p/133801#M1455</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Am I missing something, or does not the CW compiler/linker inform you about the stack usage. I am also using a Cosmic compiler for the HC08-family, and it has a very convenient stack usage map in the linker's MAP-file that tells you the total stack needed for all entry points (main() and ISRs), and from that is is easy to define the stack size. I have found the -Ll option in CW and had a look at the generated logfile.txt, but to, from that, manually calculate the total stack usage for a not so small project, would be very difficult.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;One way to determine the stack usage would of course be to examine the stack content with the debugger after the application has run for a while, but that is not a very scientific way of doing it and does not guarantee that the worst case was found.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Any ideas, anybody?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Sten&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Apr 2006 13:20:33 GMT</pubDate>
    <dc:creator>Sten</dc:creator>
    <dc:date>2006-04-27T13:20:33Z</dc:date>
    <item>
      <title>Stack usage (CWS-H12-PRO v. 4.5)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Stack-usage-CWS-H12-PRO-v-4-5/m-p/133801#M1455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Am I missing something, or does not the CW compiler/linker inform you about the stack usage. I am also using a Cosmic compiler for the HC08-family, and it has a very convenient stack usage map in the linker's MAP-file that tells you the total stack needed for all entry points (main() and ISRs), and from that is is easy to define the stack size. I have found the -Ll option in CW and had a look at the generated logfile.txt, but to, from that, manually calculate the total stack usage for a not so small project, would be very difficult.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;One way to determine the stack usage would of course be to examine the stack content with the debugger after the application has run for a while, but that is not a very scientific way of doing it and does not guarantee that the worst case was found.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Any ideas, anybody?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Sten&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Apr 2006 13:20:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Stack-usage-CWS-H12-PRO-v-4-5/m-p/133801#M1455</guid>
      <dc:creator>Sten</dc:creator>
      <dc:date>2006-04-27T13:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: Stack usage (CWS-H12-PRO v. 4.5)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Stack-usage-CWS-H12-PRO-v-4-5/m-p/133802#M1456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;This is not working in the current version of the tools, but has been recorded as a feature request for future release of the tools.&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Apr 2006 01:34:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Stack-usage-CWS-H12-PRO-v-4-5/m-p/133802#M1456</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-04-28T01:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Stack usage (CWS-H12-PRO v. 4.5)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Stack-usage-CWS-H12-PRO-v-4-5/m-p/133803#M1457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I tested the following code using the simulator for a HCS12DJ256. Not sure if this is what you are looking for though. Should be able to create a test project and paste this code into main.c&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;#include &amp;lt;hidef.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* common defines and macros */&lt;BR /&gt;#include &amp;lt;mc9s12dj256.h&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* derivative information */&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;#pragma LINK_INFO DERIVATIVE "mc9s12dj256b"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/* Define to turn on stack checking */&lt;BR /&gt;#define DEBUG_STACK&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/* Macro to calculate amount of stack used */&lt;BR /&gt;#define STACK_CHECK asm PSHX; asm TSX; asm STX StackPtr; asm PULX;\&lt;BR /&gt;&amp;nbsp;&amp;nbsp;StackUsed = StackStart - StackPtr /*; asm BGND */&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;/* Macro to save stack start */&lt;BR /&gt;#define STACK_START asm PSHX; asm TSX; asm STX StackStart; asm PULX&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/* Variables for stack checking only asllocated if DEBUG_STACK is defined */&lt;BR /&gt;#ifdef DEBUG_STACK&lt;BR /&gt;unsigned int StackPtr = 0;&lt;BR /&gt;unsigned int StackStart = 0;&lt;BR /&gt;unsigned int StackUsed = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;#endif&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/* Just some variables */&lt;BR /&gt;int i;&lt;BR /&gt;int Array[100];&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/* Just a function for testing stack usage */&lt;BR /&gt;void Function1(void){&lt;BR /&gt;&amp;nbsp;int Array2[10];&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;/* If we are stack checking do it here */&lt;BR /&gt;&amp;nbsp;#ifdef DEBUG_STACK&lt;BR /&gt;&amp;nbsp;&amp;nbsp;STACK_CHECK;&lt;BR /&gt;&amp;nbsp;#endif&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;/* Do something */&lt;BR /&gt;&amp;nbsp;for(i=0; i&amp;lt;10; i++){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;Array[i] = i;&lt;BR /&gt;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;/* Use local array so compiler does not optimize it out */&lt;BR /&gt;&amp;nbsp;Array2[0] = Array[5];&lt;BR /&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;/* Main function */&lt;BR /&gt;void main(void) {&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* Get stack starting position */&lt;BR /&gt;&amp;nbsp;#ifdef DEBUG_STACK&lt;BR /&gt;&amp;nbsp;&amp;nbsp;STACK_START;&lt;BR /&gt;&amp;nbsp;#endif&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;/* Call test function */&lt;BR /&gt;&amp;nbsp;Function1();&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;for(;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt; {} /* wait forever */&lt;BR /&gt;}&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Apr 2006 07:42:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Stack-usage-CWS-H12-PRO-v-4-5/m-p/133803#M1457</guid>
      <dc:creator>Technoman64</dc:creator>
      <dc:date>2006-04-28T07:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Stack usage (CWS-H12-PRO v. 4.5)</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Stack-usage-CWS-H12-PRO-v-4-5/m-p/133804#M1458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Thanks CrasyCat and Technoman,&lt;/P&gt;&lt;P&gt;while waiting for the feature to be included in the tools, I will use the idea with inline stack checking to collect the deepest stack during runtime.&lt;/P&gt;&lt;P&gt;Sten&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Apr 2006 11:50:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Stack-usage-CWS-H12-PRO-v-4-5/m-p/133804#M1458</guid>
      <dc:creator>Sten</dc:creator>
      <dc:date>2006-04-28T11:50:33Z</dc:date>
    </item>
  </channel>
</rss>

