<?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>8-bit MicrocontrollersのトピックRe: Increasing stack size</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Increasing-stack-size/m-p/261381#M19992</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hard to say without seeing your code, but you should be aware that local variables are on the stack to. So if you have a lot or big local variables in your functions, your stack may increase this much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eckhard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Feb 2013 12:11:11 GMT</pubDate>
    <dc:creator>eckhard</dc:creator>
    <dc:date>2013-02-18T12:11:11Z</dc:date>
    <item>
      <title>Increasing stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Increasing-stack-size/m-p/261380#M19991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a project which runs on MC9S08DZ60. This MCU has 4Kb of RAM.&lt;/P&gt;&lt;P&gt;In my current phase of project, my stack size is 0x700 bytes. &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I increment the stack size when I see bad behavior of the sw (PC goes to wrong location/variables values are changed). &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;I hardly have nested function calls. I noticed that I increase stack size if I add few function calls/new features. Why is the reason for&lt;BR /&gt;increasing the stack size if functions nested calls are 2-3 levels? &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Feb 2013 17:57:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Increasing-stack-size/m-p/261380#M19991</guid>
      <dc:creator>admin</dc:creator>
      <dc:date>2013-02-17T17:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: Increasing stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Increasing-stack-size/m-p/261381#M19992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hard to say without seeing your code, but you should be aware that local variables are on the stack to. So if you have a lot or big local variables in your functions, your stack may increase this much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eckhard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 12:11:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Increasing-stack-size/m-p/261381#M19992</guid>
      <dc:creator>eckhard</dc:creator>
      <dc:date>2013-02-18T12:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: Increasing stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Increasing-stack-size/m-p/261382#M19993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have many global variables structures and array which are on RAM but not on the stack. The problem is that when I add new functionallity to the project, in some cases i need to increase stack size.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even if I have many functions which have many local variables, I see no reason to increase the stack size to 0x800 bytes (my currently used RAM is ~3.4KbB and Flash is 15Kb).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Correct me if i am wrong, but when the CPU leaves function, all the variables are removed from the stack.&lt;BR /&gt;So what else causes the stack size to increase?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I read in a response (&lt;A href="https://community.nxp.com/message/20566"&gt;Re: Put a function into the stack)&lt;/A&gt; that when running function from stack is like running it from RAM. &lt;BR /&gt;I know that the stack is basically on the RAM. &lt;SPAN style="text-decoration: underline;"&gt;&lt;SPAN style="color: #575757; text-decoration: underline;"&gt;So do I need to increase stack size when I add more global variables?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Feb 2013 12:58:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Increasing-stack-size/m-p/261382#M19993</guid>
      <dc:creator>ngsoftuser</dc:creator>
      <dc:date>2013-02-18T12:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Increasing stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Increasing-stack-size/m-p/261383#M19994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello eran yasso,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Global variables (and also static variables) occupy a fixed,&amp;nbsp; linker determined location in RAM.&amp;nbsp; The number of global variables should have no bearing on stack size requirements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The stack is used for temporary storage of data, such as -&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Return address data for each function call.&lt;/LI&gt;&lt;LI&gt;Register values and return address data during an interrupt.&lt;/LI&gt;&lt;LI&gt;Function parameter data.&lt;/LI&gt;&lt;LI&gt;Local variables within a function.&lt;/LI&gt;&lt;LI&gt;Additional temporary variables required by library functions and operations, e.g. arithmetic operations.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The last item is quite significant if you are using floating point arithmetic, and even more so if you are using trigonometric or other complex library functions.&lt;/P&gt;&lt;P&gt;Yes, the stack space is eventually released.&amp;nbsp; The required stack size will depend of the degree of function nesting, in conjunction with the factors listed above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 05:19:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Increasing-stack-size/m-p/261383#M19994</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2013-02-19T05:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Increasing stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Increasing-stack-size/m-p/261384#M19995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello bigmac,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your raply. I agree with all what you say. The point is that I still have to increase&lt;/P&gt;&lt;P&gt;The stack size when I add more functionallity and which i have no idea why.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I added my map file maybe you can see the reason for increasing stack size.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2013 12:49:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Increasing-stack-size/m-p/261384#M19995</guid>
      <dc:creator>ngsoftuser</dc:creator>
      <dc:date>2013-02-19T12:49:23Z</dc:date>
    </item>
  </channel>
</rss>

