<?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>S12 / MagniV MicrocontrollersのトピックRe: Complier issue on MC9S12Xdp512</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Complier-issue-on-MC9S12Xdp512/m-p/194315#M7689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First of all you should mention compiler version.&amp;nbsp; If it's Codewarrior, just show exact snippet of disassembled code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STX 0x398e&lt;BR /&gt;STD 0x3985&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E and 5 at the end of address can't belong to the same 32bit variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 Sep 2012 15:48:38 GMT</pubDate>
    <dc:creator>kef</dc:creator>
    <dc:date>2012-09-04T15:48:38Z</dc:date>
    <item>
      <title>Complier issue on MC9S12Xdp512</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Complier-issue-on-MC9S12Xdp512/m-p/194314#M7688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;This is Richard from sgcc, developing on mc9s12xdp512. I met the following issue:&amp;nbsp;&lt;BR /&gt;volatile unsigned long gCounter=0; //locate at 0x2cd4&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;__interrupt timer_tick(){ //interrupt every 1ms&amp;nbsp;&lt;BR /&gt;gCounter++;&amp;nbsp;&lt;BR /&gt;}&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;unsigned long getCurrentTime()&amp;nbsp;&lt;BR /&gt;{&amp;nbsp;&lt;BR /&gt;return gCounter;&amp;nbsp;&lt;BR /&gt;}&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;unsigned long readback=0; // locate at 0x398e&amp;nbsp;&lt;BR /&gt;void main()&amp;nbsp;&lt;BR /&gt;{&amp;nbsp;&lt;BR /&gt;while(1)&amp;nbsp;&lt;BR /&gt;{&amp;nbsp;&lt;BR /&gt;readback = getCurrentTime(); // Assembly: CALL 0xc793, 00&amp;nbsp;&lt;BR /&gt;LDX 0x2cd4&amp;nbsp;&lt;BR /&gt;LDD 0x2cd6&amp;nbsp;&lt;BR /&gt;RTC&amp;nbsp;&lt;BR /&gt;SEX D,X&amp;nbsp;&lt;BR /&gt;STX 0x398e&amp;nbsp;&lt;BR /&gt;STD 0x3985&amp;nbsp;&lt;BR /&gt;....delay;&amp;nbsp;&lt;BR /&gt;}&amp;nbsp;&lt;BR /&gt;}&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The problem is:&amp;nbsp;&lt;BR /&gt;as gCounter increase, for example gCounter = 0x18001;&amp;nbsp;&lt;BR /&gt;LDX 0x2cd4&amp;nbsp;&lt;BR /&gt;LDD 0x2cd6&amp;nbsp;&lt;BR /&gt;//Here, IX=1, D=0x8001&amp;nbsp;&lt;BR /&gt;RTC&amp;nbsp;&lt;BR /&gt;SEX D,X&amp;nbsp;&lt;BR /&gt;// Here, IX changes from 1 to 0xffff, cuz' the highest bit of D is "1".&amp;nbsp;&lt;BR /&gt;STX 0x398e&amp;nbsp;&lt;BR /&gt;STD 0x3985&amp;nbsp;&lt;BR /&gt;// Here, readback = 0xffff8001.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I don't know why "SEX D,X" is inserted and leads to the strange result.---- only lower word of gCounter is assgined to feedback, and the&lt;SPAN style="line-height: 15px;"&gt;&amp;nbsp;&lt;/SPAN&gt;higher word is wrong. how could i avoid the comiler to do such things which really take me much time to find the bug out.&amp;nbsp;&lt;BR /&gt;see attachment for sample code and snapshot. plz rename the file to .rar and extract first.&lt;BR /&gt;Debug suggest:&amp;nbsp;&lt;BR /&gt;See the communication.c for the bug. Don't worry about other modules. Just run the project, and set a breakpoint at gChargeManager.timeStamp=GetCurrentTime(); Then u can see from the assembly window that "SEX D,X" is inserted. Then add expressions "gTimerCount"(increased by interrupt every 1ms) and "gChargeManager.timeStamp"(assigned by GetCurrenttime(), gTimerCount), remove the breakpoint to run, u will see the issue&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Sep 2012 14:58:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Complier-issue-on-MC9S12Xdp512/m-p/194314#M7688</guid>
      <dc:creator>richardlin</dc:creator>
      <dc:date>2012-09-04T14:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Complier issue on MC9S12Xdp512</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Complier-issue-on-MC9S12Xdp512/m-p/194315#M7689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First of all you should mention compiler version.&amp;nbsp; If it's Codewarrior, just show exact snippet of disassembled code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STX 0x398e&lt;BR /&gt;STD 0x3985&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E and 5 at the end of address can't belong to the same 32bit variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Sep 2012 15:48:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Complier-issue-on-MC9S12Xdp512/m-p/194315#M7689</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2012-09-04T15:48:38Z</dc:date>
    </item>
  </channel>
</rss>

