<?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: Adapt9s12XD512 non-functioning caused by function call in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206695#M8420</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am not sure whether the following issue has already been alluded to -&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;for (i = 0; i &amp;lt; 682; i++) {&lt;BR /&gt;&amp;nbsp; if( (alldata[i]&amp;gt;10) &amp;amp;&amp;amp; alldata[i+1]&amp;lt;10)&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; alldata[i+1] = (alldata[i] + 2);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;If the array size is 682 words, valid indices are from 0 to 681.&amp;nbsp; However, since i will have a maximum value of 681, a reference to &lt;FONT face="Courier New"&gt;alldata[i+1]&lt;/FONT&gt; would be invalid for this case.&amp;nbsp; The upper bound of the &lt;FONT face="Courier New"&gt;for&lt;/FONT&gt; loop should be limited to &lt;FONT face="Courier New"&gt;i&amp;lt;681&lt;/FONT&gt;&lt;FONT face="Arial"&gt;.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If the value of the local variable i happened to be over-written because of this error, it is possible that the function would never exit.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;What attempts have you made to simulate the operation?&amp;nbsp; This may better show what is happening as you run the function.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2008-03-27&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;02:03 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Mar 2008 09:56:39 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2008-03-27T09:56:39Z</dc:date>
    <item>
      <title>Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206682#M8407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;I wrote a function for use in my program that does nothing more than loop through an int array[683] a few times making comparisons in order to analyze sensor data.&amp;nbsp;It does nothing more than test for different cases and save some integers in a global array.&amp;nbsp; It runs fine on the computer using a C compiler. It is, however, perhaps&amp;nbsp;a little lengthy to post here(but i will do so in the &lt;STRONG&gt;following post&lt;/STRONG&gt;).&amp;nbsp; It compiles fine in code warrior with no errors, but I get a warning: L1912: Object _vectab overlaps with another (last addr: 0xEB5F, object addr: 0xCF00)&lt;/DIV&gt;&lt;DIV&gt;Anyway, here is the problem:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;When I load the function but don't call it, everything works fine, but when I call the function, &lt;STRONG&gt;the microcontroller does NOTHING&lt;/STRONG&gt;.&amp;nbsp; &lt;STRONG&gt;It doesn't run any of the code before the function call&lt;/STRONG&gt;, or after it, or at least not correctly, as the code does several things that can be observed (like flash an onboard LED).&amp;nbsp; I can't find any indication that the program is too big, or does anything that the microcontroller can't handle.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I will try to clean up the code (lots of things commented out left in it) for the following post.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Why does the following function cause the microcontroller not to function at all?&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by ODU IEEE Car Team on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2008-03-26&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;12:46 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2008 19:34:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206682#M8407</guid>
      <dc:creator>ODUIEEECarTeam</dc:creator>
      <dc:date>2008-03-26T19:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206683#M8408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;#pragma CODE_SEG __NEAR_SEG NON_BANKED&lt;BR /&gt;void FIND_TARGET()&lt;BR /&gt;{&amp;nbsp;&lt;BR /&gt;int alldata[682]={99};&lt;BR /&gt;int desiredtargets[10]={99};&lt;BR /&gt;int desiredtargetsloc[10]={99};&lt;BR /&gt;int i=0;&lt;BR /&gt;int c=0;&lt;/DIV&gt;&lt;DIV&gt;for(i=0;i&amp;lt;682;i++)&lt;BR /&gt;{&lt;BR /&gt;alldata[i]=_array1[i];&lt;BR /&gt;}&lt;/DIV&gt;&lt;DIV&gt;for (i=0;i&amp;lt;682;i++)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; if( (alldata[i]&amp;gt;10) &amp;amp;&amp;amp; alldata[i+1]&amp;lt;10)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;alldata[i+1] = (alldata[i] + 2);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;alldata[i]=alldata[i+1];&lt;BR /&gt;desiredtargetsloc[i] = i;&lt;BR /&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; for (i=0;i&amp;lt;682;i++)&lt;BR /&gt;&amp;nbsp; {&amp;nbsp;&lt;BR /&gt;&amp;nbsp;if ( alldata[i]&amp;gt;10) //all data greater than 10&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;if((alldata[i+1]&amp;lt; alldata[i]) &amp;amp;&amp;amp; (alldata[i+1]&amp;gt;10) )&lt;BR /&gt;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (!( alldata[i+1] &amp;gt; (alldata[i] -50) ))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;desiredtargets[c] = alldata[i+1];&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;desiredtargetsloc[c] = i+3;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;c++;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; alldata[i]=alldata[i+1];&lt;BR /&gt;&amp;nbsp;}&lt;/DIV&gt;&lt;DIV&gt;for (i=0;i&amp;lt;c;i++) //searches for closest distance angle&lt;BR /&gt;{&lt;BR /&gt;if (desiredtargets[i]&amp;lt;desiredtargets[i+1])&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp; desiredtargetsloc[i+1]=desiredtargetsloc[i];&lt;BR /&gt;&amp;nbsp;desiredtargets[i+1]=desiredtargets[i];&lt;BR /&gt;&amp;nbsp;}&lt;BR /&gt;targetdist=desiredtargets[i];&lt;BR /&gt;targetloc=desiredtargetsloc[i];&lt;BR /&gt;}&lt;BR /&gt;}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //end of gettarget&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2008 19:52:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206683#M8408</guid>
      <dc:creator>ODUIEEECarTeam</dc:creator>
      <dc:date>2008-03-26T19:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206684#M8409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;The warning message indicates that something is trying to occupy the same space as your interrupt vector table. Possibly when the function runs, it smashes the vector table in short order, and then everything stops working. Things to check:&lt;BR /&gt;&lt;BR /&gt;1) Look closely at the map files geneated by the linker and see where the overlap is. Move the offending function if possible.&lt;BR /&gt;2) Non-banked memory is limited. Does your function really have to be there? Can it go into another memory bank?&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2008 23:18:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206684#M8409</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2008-03-26T23:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206685#M8410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;You have a very large amount of local variables in the function.&amp;nbsp; You need to make sure you have enough stack space to accomadate for this, this function alone requires 1408 bytes on the stack!&amp;nbsp; Also, you are then initializing 704 int's on the stack&amp;nbsp;to 99.&amp;nbsp; Is this really necessary?&amp;nbsp;&amp;nbsp;The compiler doesn't make a for loop to do this initialization, it does it all in line.&amp;nbsp; This means it adds more than 704 lines of asm to do this.&amp;nbsp;&amp;nbsp;This isn't needed with alldata as it is initialized with the first for loop.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Also,&amp;nbsp;a quick&amp;nbsp;check showed&amp;nbsp;a few problems like&amp;nbsp;with desiredtargetsloc in the second for loop.&amp;nbsp; You try to set 682 values of&amp;nbsp;desiredtargetsloc to 1-682 but this array only contains 10 bytes. You might want to look over the rest of the function for anymore problems like these.&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 00:06:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206685#M8410</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2008-03-27T00:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206686#M8411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;For what's worth:&lt;BR /&gt;&lt;BR /&gt;int alldata[682]={99};&lt;BR /&gt;&lt;BR /&gt;Only initializes&amp;nbsp; alldata[0] to 99. However the compiler will then 0 fill the reset of the array, and it will cost you about 4 * 682 bytes in flash with the HC12 compiler.&lt;BR /&gt;&lt;BR /&gt;As stated above, the line&lt;BR /&gt;desiredtargetsloc[i] = i;&lt;BR /&gt;in the first for loop, which in invariant (meaning it will go from 0 to 681 always) will be crash the stack, even if it was large enough to begin with.&lt;BR /&gt;Also the index variable c is unbounded, and depending on the data in the arrays may also exceed the bounds of the array.&amp;nbsp;&amp;nbsp; (desiredtargets[c] = alldata[i+1]; &amp;nbsp;&amp;nbsp; desiredtargetsloc[c] = i+3&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;&lt;BR /&gt;&lt;BR /&gt;If you never call the function, then the linker will not include it, which is why it works when you don't call it, so I would say that it is indeed over running something just due to it's size which is about 2728 bytes JUST for the local variable initialization.&lt;BR /&gt;&lt;BR /&gt;If you ran this else where, you must have lucked out and what ever you ran it on failed to detect the apparent stack crash.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 00:47:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206686#M8411</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-03-27T00:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206687#M8412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I thought I didn't much have to worry about memory since i have :Memory&lt;BR /&gt;– 512K byte Flash EEPROM&lt;BR /&gt;– 4K byte EEPROM&lt;BR /&gt;– 32K byte RAM&lt;BR /&gt;&lt;BR /&gt;Anyway, I know I can make the program more efficient, but my whole program is still going to get bigger.&amp;nbsp;&lt;BR /&gt;I changed #pragma CODE_SEG __NEAR_SEG NON_BANKED&lt;BR /&gt;to #pragma CODE_SEG __NEAR_SEG BANKED&lt;BR /&gt;on several of my large functions. and this gets rid of the warning. However, the problem is the same. the program does nothing.&amp;nbsp; No warnings (other than the usual possible loss of data).&amp;nbsp;&lt;BR /&gt;I also have a #include &amp;lt;math.h&amp;gt;&lt;BR /&gt;&lt;BR /&gt;Do I have to do anything special to use banked memory? What could cause this total program failure?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 03:39:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206687#M8412</guid>
      <dc:creator>ODUIEEECarTeam</dc:creator>
      <dc:date>2008-03-27T03:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206688#M8413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;ODU IEEE Car Team wrote:&lt;BR /&gt;I thought I didn't much have to worry about memory since i have :Memory&lt;BR /&gt;– 512K byte Flash EEPROM&lt;BR /&gt;– 4K byte EEPROM&lt;BR /&gt;– 32K byte RAM&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;While you do have a fair amount of ROM, the amount of non-banked ROM you have is still restricted(~32K).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Did you fix the problems noted by Jim and change the size allocated for your stack?&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 04:13:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206688#M8413</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2008-03-27T04:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206689#M8414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Also, When I open the debugger, my assembly code is "[hex] staa 0x5A" like a million times or so, and that's all, except for a few statements before the seemingly infinite staa 0x5A.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 04:36:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206689#M8414</guid>
      <dc:creator>ODUIEEECarTeam</dc:creator>
      <dc:date>2008-03-27T04:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206690#M8415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;I got rid of the initialization of the arrays. it was not necesary.&amp;nbsp; as for one problem about assigning 683 values to an array of size 10, that is not a problem because this has been tested and that case only ever happens about 6 times. I increased the size anyway though.&lt;BR /&gt;&amp;nbsp;I changed several functions to banked memory and that eliminated the warnings, but not the problem, what is the practical difference between using banked vs. non-banked?&lt;BR /&gt;is there any other code necessary to use banked?&lt;BR /&gt;&lt;BR /&gt;How do you change the size of your stack?&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by ODU IEEE Car Team on &lt;SPAN class="date_text"&gt;2008-03-26&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;09:43 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 04:38:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206690#M8415</guid>
      <dc:creator>ODUIEEECarTeam</dc:creator>
      <dc:date>2008-03-27T04:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206691#M8416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;int desiredtargetsloc[10];

 Only happens 6 times????
 What did I miss?

for (i=0;i&amp;lt;682;i++){  if( (alldata[i]&amp;gt;10) &amp;amp;&amp;amp; alldata[i+1]&amp;lt;10)  {   alldata[i+1] = (alldata[i] + 2);  }  alldata[i]=alldata[i+1];  desiredtargetsloc[i] = i;}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 04:44:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206691#M8416</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-03-27T04:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206692#M8417</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;nvm. this is a problem. I messed up, there used to be something different there, sorry.&amp;nbsp; It was already fixed after I pasted that code, so I didn't look at what I posted closely.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by ODU IEEE Car Team on &lt;SPAN class="date_text"&gt;2008-03-26&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:02 PM&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by ODU IEEE Car Team on &lt;SPAN class="date_text"&gt;2008-03-26&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:04 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 05:00:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206692#M8417</guid>
      <dc:creator>ODUIEEECarTeam</dc:creator>
      <dc:date>2008-03-27T05:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206693#M8418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;You need to change the value of STACKSIZE in your prm file to change the value of your stack. You will have to set the size of the stack depending on the size of local variables used in other functions and which functions call which other functions.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;There were 2 pieces of code that could have been problems, I think you are referring to the second one.&amp;nbsp; Jim pointed out above the one that needs fixed for sure.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;- Brett&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 05:00:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206693#M8418</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2008-03-27T05:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206694#M8419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;both of those problems are fixed and the stack size is set to 4K, and the problem remains. It won't even flash an LED still.&amp;nbsp; It doesn't run even when i comment out the function call now that i changed 3 large functions to banked. I get no errors. no warnings.&lt;BR /&gt;&lt;BR /&gt;I now have 3 functions like this:&lt;BR /&gt;#pragma CODE_SEG __NEAR_SEG BANKED&lt;BR /&gt;void SetParameters(){...very large function...}&lt;BR /&gt;&lt;BR /&gt;Is this right? i can still just call the function with "SetParameters();" right?&lt;BR /&gt;this eliminates the errors, but nothing works still.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by ODU IEEE Car Team on &lt;SPAN class="date_text"&gt;2008-03-26&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:22 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 05:13:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206694#M8419</guid>
      <dc:creator>ODUIEEECarTeam</dc:creator>
      <dc:date>2008-03-27T05:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206695#M8420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am not sure whether the following issue has already been alluded to -&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;for (i = 0; i &amp;lt; 682; i++) {&lt;BR /&gt;&amp;nbsp; if( (alldata[i]&amp;gt;10) &amp;amp;&amp;amp; alldata[i+1]&amp;lt;10)&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; alldata[i+1] = (alldata[i] + 2);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;If the array size is 682 words, valid indices are from 0 to 681.&amp;nbsp; However, since i will have a maximum value of 681, a reference to &lt;FONT face="Courier New"&gt;alldata[i+1]&lt;/FONT&gt; would be invalid for this case.&amp;nbsp; The upper bound of the &lt;FONT face="Courier New"&gt;for&lt;/FONT&gt; loop should be limited to &lt;FONT face="Courier New"&gt;i&amp;lt;681&lt;/FONT&gt;&lt;FONT face="Arial"&gt;.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If the value of the local variable i happened to be over-written because of this error, it is possible that the function would never exit.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;What attempts have you made to simulate the operation?&amp;nbsp; This may better show what is happening as you run the function.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2008-03-27&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;02:03 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 09:56:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206695#M8420</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-03-27T09:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206696#M8421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&amp;gt;#pragma CODE_SEG __NEAR_SEG BANKED&lt;BR /&gt;That does look suspicios.&lt;BR /&gt;The __NEAR_SEG basically says the function is reachable in a non banked area. Using this together with a section named BANKED looks suspect, if you use the banked memory model (I guess so) do not explicitely use the __NEAR_SEG qualifier unless that code is really ending up non banked.&lt;BR /&gt;(or very advanced: is really only called from the same page, but I would not start with such optimizations).&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Mar 2008 10:35:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206696#M8421</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-03-27T10:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206697#M8422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the CodeWarrior directory, go to the (CodeWarrior Examples) directory and study and the example code in the BankedData, GlobalAddressing, and StringTable directories. In particular, StringTable shows how to allocate string literals in Flash.&lt;BR /&gt;&lt;BR /&gt;Also, you may want to study the memory map for your MCU in the attached PDF.&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/files/microcontrollers/doc/prod_brief/9S12XDFAMPP.pdf" rel="nofollow" target="_self"&gt;9S12XDFAMPP.pdf&lt;/A&gt;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by t.dowe on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-08-31&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;05:12 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2008 22:24:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206697#M8422</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2008-03-28T22:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206698#M8423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;If you are using Special Edition you have a 32K limit, so if this is the case, I would go back to a non-banked project and fore go the headaches. You can get a full 32K of code without using banked model.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2008 22:35:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206698#M8423</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-03-28T22:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206699#M8424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;First of all, ignore the previously posted code for future reference to this thread.&amp;nbsp; It has been fixed and besides the few errors (a result of cleaning the code up for the post),&amp;nbsp; it is not the problem.&amp;nbsp;&lt;BR /&gt;We have torn apart and rebuilt our project several times, adding each verified function or set of verified functions piece by piece.&amp;nbsp; into the new project, confirming functionality at each step.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The problem that consistently stops our progress is that it seems to get to large.&amp;nbsp; and we get warnings: L1912: Object &amp;lt;obj&amp;gt; overlaps with another (last addr: &amp;lt;addr&amp;gt;, object address: &amp;lt;objadr&amp;gt;)&lt;BR /&gt;(the object is usually _vectab)&lt;BR /&gt;&lt;BR /&gt;I am completely unfamiliar with most things related to solving this problem and we only have a few days left (I remember the meaning banked memory from it's mention in class, but that's about it), so I have a series of questions:&lt;BR /&gt;&lt;BR /&gt;I am using the special edition of code warrior, which should give me 32k to run my program without messing with changing my "#pragma CODE_SEG __NEAR_SEG NON_BANKED" statements right?&lt;BR /&gt;&lt;BR /&gt;– 512K byte Flash EEPROM&lt;BR /&gt;– 4K byte EEPROM&lt;BR /&gt;– 32K byte RAM&lt;BR /&gt;These are the specs of my controller, but I can't seem to figure out what is saved where.&amp;nbsp; and what numbers mean what.&amp;nbsp; &lt;B&gt;When I comment out a large sections&lt;/B&gt; of logical tests, my program runs correctly, and I can find 3 numbers that relate to size:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;At the bottom of the project:&lt;BR /&gt;code: 11k, data: 8k&lt;BR /&gt;In the bin folder:&lt;BR /&gt;Full_Chip_Simulation.abs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 296KB&lt;BR /&gt;Full_Chip_Simulation.abs.glo&amp;nbsp;&amp;nbsp;&amp;nbsp; 10KB&lt;BR /&gt;Full_Chip_Simulation.abs.s19&amp;nbsp;&amp;nbsp; 10KB&lt;BR /&gt;Full_Chip_Simulation.map&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 219KB&lt;BR /&gt;&lt;BR /&gt;&lt;B&gt;When I uncomment all the code that works independently&lt;/B&gt; (it is I can comment out different parts and the other parts will work, but not all of them in one) I get total, or almost total non-functioning including code before the overlapping objects are used:&lt;BR /&gt;&lt;BR /&gt;At the bottom of the project:&lt;BR /&gt;code: 12k, data: 8k&lt;BR /&gt;In the bin folder:&lt;BR /&gt;Full_Chip_Simulation.abs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 297KB&lt;BR /&gt;Full_Chip_Simulation.abs.glo&amp;nbsp;&amp;nbsp;&amp;nbsp; 11KB&lt;BR /&gt;Full_Chip_Simulation.abs.s19&amp;nbsp;&amp;nbsp; 11KB&lt;BR /&gt;Full_Chip_Simulation.map&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 220KB&lt;BR /&gt;&lt;BR /&gt;I can't seem to find anything that relates this increase in these numbers to why my code loses functionality.&lt;BR /&gt;&lt;U&gt;What is significant about this specific increase?&lt;BR /&gt;&lt;BR /&gt;What can I do to avoid this apparent running out of space without reducing the size of my code (which still needs to get bigger)?&lt;BR /&gt;&lt;/U&gt;&lt;BR /&gt;Also, I talked to a grad student experienced in this sort of thing briefly, who dismissed this and said I had plenty of space, and based on the numbers I see, he appears to be right, but based on the problems I'm getting, he appears to be wrong.&amp;nbsp; We're totally stuck.&lt;BR /&gt;&lt;BR /&gt;Thanks to everyone for your help.&amp;nbsp;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Mar 2008 18:37:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206699#M8424</guid>
      <dc:creator>ODUIEEECarTeam</dc:creator>
      <dc:date>2008-03-30T18:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206700#M8425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;After commenting out lines of code one at a time, I found that the overlap begins exactly when my code goes over 12K.&amp;nbsp; What is special about 12K?&amp;nbsp; I don't see anything that specifies a 12K limit on anything.&amp;nbsp; The only relation I can make is that this is also when my main.c+isrvectors.c+startup code equals very close to 4K (3757+255+52=4064), which is the size of my EEPROM, but I didn't think this mattered because I have 512K flash, and can use up to 32k without having to deal with memory locations right?&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Mar 2008 19:27:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206700#M8425</guid>
      <dc:creator>ODUIEEECarTeam</dc:creator>
      <dc:date>2008-03-30T19:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Adapt9s12XD512 non-functioning caused by function call</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206701#M8426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I believe there is 12K of non paged ram on this device.&lt;BR /&gt;Post your PRM file, perhaps you are placing the code in ram???&lt;BR /&gt;&lt;BR /&gt;I know if you were using DBG-12 this would be the case.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Mar 2008 21:32:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Adapt9s12XD512-non-functioning-caused-by-function-call/m-p/206701#M8426</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-03-30T21:32:29Z</dc:date>
    </item>
  </channel>
</rss>

