<?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: HCS08 (MC13213), global variable allocation problem! in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08-MC13213-global-variable-allocation-problem/m-p/205673#M17232</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact the more global variables you define, the longer the startup code will need to initialize them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you really have a large amount of global variables in your application you may want to add option -D_DO_FEED_COP_&amp;nbsp; to your command line when building start08.c.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will add code to feed the COP in the startup function itself and prevent the COP reset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Aug 2009 21:57:43 GMT</pubDate>
    <dc:creator>CrasyCat</dc:creator>
    <dc:date>2009-08-10T21:57:43Z</dc:date>
    <item>
      <title>HCS08 (MC13213), global variable allocation problem!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08-MC13213-global-variable-allocation-problem/m-p/205669#M17228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please try to find an explanation for this! The situation is as simple as this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. I create a new project in code warrior 5.9 for MC13213&lt;/P&gt;&lt;P&gt;(ANSI stratup code, small memory model)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. I declare these 2 global arrays:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;typedef unsigned char uint8_t;&lt;BR /&gt;typedef unsigned short uint16_t;&lt;BR /&gt;typedef unsigned long uint32_t;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;typedef struct datetime_tag {&lt;BR /&gt;&amp;nbsp; uint16_t year;&lt;BR /&gt;&amp;nbsp; uint8_t month;&lt;BR /&gt;&amp;nbsp; uint8_t day;&lt;BR /&gt;&amp;nbsp; uint8_t hours;&lt;BR /&gt;&amp;nbsp; uint8_t minutes;&lt;BR /&gt;&amp;nbsp; uint8_t seconds;&lt;BR /&gt;} tDateTime;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tDateTime timestamp[96];&lt;BR /&gt;uint32_t impulse[96];&lt;/P&gt;&lt;P&gt;3. My main is like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void main(void) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SOPT = 0x33;&lt;/P&gt;&lt;P&gt;&amp;nbsp; impulse[10] = 1;&lt;BR /&gt;&amp;nbsp; timestamp[10].seconds = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(;&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt; {&lt;BR /&gt;&amp;nbsp; } /* loop forever */&lt;BR /&gt;&amp;nbsp; /* please make sure that you never leave main */&lt;/P&gt;&lt;P&gt;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. Compile OK + Programming OK + Trying to debug&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5. !! The program jumps back to INIT_SP_FROM_STARTUP_DESC(); which is in the Start08.c&lt;/P&gt;&lt;P&gt;&amp;nbsp; What' s this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;6. The strangest thing: I declare another global variable: uint8_t DUMMY[2300]; And I put DUMMY[2] = 1; so that the array is really allocated in the RAM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;7. Programming, trying to debug -&amp;gt; and the program works fine!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really don't understand what is behind this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2009 15:30:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08-MC13213-global-variable-allocation-problem/m-p/205669#M17228</guid>
      <dc:creator>zoz</dc:creator>
      <dc:date>2009-08-06T15:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08 (MC13213), global variable allocation problem!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08-MC13213-global-variable-allocation-problem/m-p/205670#M17229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;zoz wrote:&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;5. !! The program jumps back to INIT_SP_FROM_STARTUP_DESC(); which is in the Start08.c. What' s this?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This indicates that a reset has occurred.&amp;nbsp; You would need to examine the SRS register for the source of the reset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested your code fragment under full chip simulation, without any problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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>Fri, 07 Aug 2009 01:05:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08-MC13213-global-variable-allocation-problem/m-p/205670#M17229</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2009-08-07T01:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08 (MC13213), global variable allocation problem!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08-MC13213-global-variable-allocation-problem/m-p/205671#M17230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This looks like a COP interrupt is generated.&lt;/P&gt;&lt;P&gt;Please clear the COP interrupt somewhere in the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Aug 2009 15:41:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08-MC13213-global-variable-allocation-problem/m-p/205671#M17230</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2009-08-08T15:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08 (MC13213), global variable allocation problem!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08-MC13213-global-variable-allocation-problem/m-p/205672#M17231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the replies, I had to put&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __RESET_WATCHDOG();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;before my first line:&lt;BR /&gt;&amp;nbsp;&amp;nbsp; SOPT = 0x33;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and this solved the problem!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I find it little bit strange though. The amount of allocated global variables in RAM had an influence on this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2009 15:29:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08-MC13213-global-variable-allocation-problem/m-p/205672#M17231</guid>
      <dc:creator>zoz</dc:creator>
      <dc:date>2009-08-10T15:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: HCS08 (MC13213), global variable allocation problem!</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08-MC13213-global-variable-allocation-problem/m-p/205673#M17232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact the more global variables you define, the longer the startup code will need to initialize them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you really have a large amount of global variables in your application you may want to add option -D_DO_FEED_COP_&amp;nbsp; to your command line when building start08.c.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will add code to feed the COP in the startup function itself and prevent the COP reset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2009 21:57:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HCS08-MC13213-global-variable-allocation-problem/m-p/205673#M17232</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2009-08-10T21:57:43Z</dc:date>
    </item>
  </channel>
</rss>

