<?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>topic Re: Local Variables in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139056#M2259</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;One thing that I have noticed, is that sometimes the compiler places some of the local variables in direct-access RAM or other location that the debugger indicates as 'unallocated'. The debugger therefore cannot trace them. &lt;BR /&gt;&lt;BR /&gt;However, the variables are indeed allcated and the code executes without any problem.&lt;BR /&gt;&lt;BR /&gt;If you need to debug those specific variables, you can declare them globally, so that the debugger can trace them. &lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Alex&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Jun 2006 20:45:24 GMT</pubDate>
    <dc:creator>alex_spotw</dc:creator>
    <dc:date>2006-06-09T20:45:24Z</dc:date>
    <item>
      <title>Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139055#M2258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;I've some problem with CW 5.0! I'm not able to initialize local varible inside functions.&lt;/DIV&gt;&lt;DIV&gt;For example:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;void Kernel (INTERFACE *p)&lt;BR /&gt;{&lt;BR /&gt;unsigned char tmp = 0;&lt;BR /&gt;static unsigned char basetime = 0;&lt;/DIV&gt;&lt;DIV&gt;...&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;When I run the Debugger HiWave, and I stop the application inside the function, the local variables have undefined values!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Why Does it Happens? Is there any option to set?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Bye&lt;/DIV&gt;&lt;DIV&gt;Andrew&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jun 2006 18:50:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139055#M2258</guid>
      <dc:creator>Andrew</dc:creator>
      <dc:date>2006-06-09T18:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139056#M2259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;One thing that I have noticed, is that sometimes the compiler places some of the local variables in direct-access RAM or other location that the debugger indicates as 'unallocated'. The debugger therefore cannot trace them. &lt;BR /&gt;&lt;BR /&gt;However, the variables are indeed allcated and the code executes without any problem.&lt;BR /&gt;&lt;BR /&gt;If you need to debug those specific variables, you can declare them globally, so that the debugger can trace them. &lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Alex&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jun 2006 20:45:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139056#M2259</guid>
      <dc:creator>alex_spotw</dc:creator>
      <dc:date>2006-06-09T20:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139057#M2260</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 pretty much depends on the context of the function.&lt;/P&gt;&lt;P&gt;Depending how often the local variable is accessed and on the whole context of the function, local variables might be kept into register, thus they will appear as undefined in the debugger.&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jun 2006 20:51:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139057#M2260</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-06-09T20:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139058#M2261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hello Alex,&lt;/P&gt;&lt;P&gt;unfortunately is not only a problem&amp;nbsp;on debugging&amp;nbsp;variables and viewing their values, but the application takes the wrong values!&lt;/P&gt;&lt;P&gt;For the standard local variables, I can initialize them in the code, but it is not possible for the static ones: I must initialize them only one time!&lt;/P&gt;&lt;P&gt;I use MC9S08GT32 (BDM Interface) in combination with CW5.0&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jun 2006 20:59:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139058#M2261</guid>
      <dc:creator>Andrew</dc:creator>
      <dc:date>2006-06-09T20:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139059#M2262</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;Are you using the standard startup code delivered by CodeWarrior or did you modify it or comment something out?&lt;/P&gt;&lt;P&gt;static local variables are handled like global variables and need to be initialized at startup.&lt;/P&gt;&lt;P&gt;CasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jun 2006 21:09:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139059#M2262</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-06-09T21:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139060#M2263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;I'm using the standard Start08.c file located in the SRC directory inside the CW Lib. The problem is not only in the static variables, but in the local non static, too!&lt;/P&gt;&lt;P&gt;I'm thinking it is a bug of the compiler/debugger!&lt;/P&gt;&lt;P&gt;Do you have other tips?&lt;/P&gt;&lt;P&gt;Regard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jun 2006 21:59:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139060#M2263</guid>
      <dc:creator>Andrew</dc:creator>
      <dc:date>2006-06-09T21:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139061#M2264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Have you tried to init the explicitly, after their declaration ? example: unsigned char tmp; &lt;BR /&gt; tmp = 0;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; Greetings&lt;BR /&gt; Sebastián&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jun 2006 22:44:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139061#M2264</guid>
      <dc:creator>Guilly</dc:creator>
      <dc:date>2006-06-09T22:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139062#M2265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hallo Sebastián,&lt;/P&gt;&lt;P&gt;Yes, I've tried and it resolves the problem for the non static variables, but the problem remaines for the static ones!&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jun 2006 23:06:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139062#M2265</guid>
      <dc:creator>Andrew</dc:creator>
      <dc:date>2006-06-09T23:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139063#M2266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Can you provide a complete project (zipped) here? I think this is most likely a configuration/debugging problem, but without an actual thing to look at I cannot say for sure. Best would be a project for the simulator.&lt;BR /&gt;&lt;BR /&gt;In C, local (non static) variables are not initialized by default unless you do write the initialization (as you did in your snippet).&lt;BR /&gt;&lt;BR /&gt;Another thing is the memory model. The tiny memory model does only support to init variables in the zero page. So which memory model are you using, an complete sample would realy help.&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Jun 2006 02:49:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139063#M2266</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2006-06-10T02:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139064#M2267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;For HC08 projects there are two options: ANSI C startup code and minimal startup code. If you pick minimal, it will only set the stack pointer and nothing more. Globals and statics will not be initialized.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 13:14:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139064#M2267</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2006-06-12T13:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139065#M2268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Eureka,&lt;/P&gt;&lt;P&gt;I've solved the problem, but I don't know how! The only way to solve the problem was to rebuild the project from scratch, using the files proposed from the wizard.&lt;/P&gt;&lt;P&gt;The project was build with CW 3.1 and ported to CW5.0: peraphs the problem was in the porting procedure, but I'm not sure!&lt;/P&gt;&lt;P&gt;Thanks to everyone&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 20:05:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139065#M2268</guid>
      <dc:creator>Andrew</dc:creator>
      <dc:date>2006-06-12T20:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Local Variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139066#M2269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I had the same problem.&amp;nbsp; My solution was to eliminate the following commad line arguement from the either the Compiler or Assmebler (I don't remember which) from your "Standard Settings"&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;__ONLY_INIT_SP&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;After I eliminated that, everthing was initialized correctly.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Hope this helps people,&lt;/DIV&gt;&lt;DIV&gt;Tomahawk&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 20:45:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Local-Variables/m-p/139066#M2269</guid>
      <dc:creator>admin</dc:creator>
      <dc:date>2006-06-12T20:45:40Z</dc:date>
    </item>
  </channel>
</rss>

