<?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>CodeWarrior for MCUのトピックRe: help with technical note TN228 CW5.7 9s08RE16</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187852#M6630</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;1) Yes, 0x0000 is an unexpected address. 0x2000 is expected.&lt;BR /&gt;&lt;BR /&gt;2) 9S12NE64, banked memory model.&lt;BR /&gt;&lt;BR /&gt;3) Yes, ram_updater() is using the default far.&lt;BR /&gt;&lt;BR /&gt;Have tried putting the calling routine in #pragma CODE_SEG NON_BANKED same as my interrupt service routines but am getting C3801 complaints. Just how do I determine what attributes the compiler thinks are different?&lt;BR /&gt;&lt;BR /&gt;Once Upon A Time I found documentation in the online help on the difference in byte orders for far objects. Believe there were example macros for converting. Can't find that now.&lt;BR /&gt;&lt;BR /&gt;For lack of the above macros I thought to try something else. Created a big union for plucking parts out of a value:&lt;BR /&gt;&lt;BR /&gt;typedef union {&lt;BR /&gt;&lt;BR /&gt;struct {&lt;BR /&gt;UINT08 a, b, c, d;&lt;BR /&gt;} bytes;&lt;BR /&gt;&lt;BR /&gt;struct {&lt;BR /&gt;UINT08 a;&lt;BR /&gt;UINT16 bc;&lt;BR /&gt;UINT08 d;&lt;BR /&gt;} mixed;&lt;BR /&gt;&lt;BR /&gt;struct {&lt;BR /&gt;UINT16 ab, cd;&lt;BR /&gt;} words;&lt;BR /&gt;&lt;BR /&gt;UINT32 u32;&lt;BR /&gt;&lt;BR /&gt;} FAR_EXPERIMENT;&lt;BR /&gt;&lt;BR /&gt;And now the disassembly looks correct:&lt;BR /&gt;&lt;BR /&gt;373: UINT16 *far source;&lt;BR /&gt;374: UINT16 *dest;&lt;BR /&gt;375: FAR_EXPERIMENT addr;&lt;BR /&gt;376:&lt;BR /&gt;377: addr.u32 = (UINT32)&amp;amp;ram_updater&lt;BR /&gt;0002 cc0000 [2] LDD #ram_updater&lt;BR /&gt;378:&lt;BR /&gt;379: // Multiple casts to mute compiler warning&lt;BR /&gt;380: dest = (UINT16*)addr.words.cd;&lt;BR /&gt;0005 6c83 [2] STD 3,SP&lt;BR /&gt;&lt;BR /&gt;Which prompted me to try a similar reduced version:&lt;BR /&gt;&lt;BR /&gt;dest = (UINT16*)((UINT32)&amp;amp;ram_updater);&lt;BR /&gt;&lt;BR /&gt;which I tried before my first post and for some reason didn't believe it worked. Am using the same trick somewhere else, upcasting to UINT32 before pulling it back down into something smaller. IIRC am using it elsewhere because it locally mutes the "loss of precision" warning in a situation that loss of precision is exactly what I wanted but for some reason was too lazy to do the union/struct thing above.&lt;BR /&gt;&lt;BR /&gt;Next: figure out what I have to do to debug code that has been relocated to RAM. First attempt the debugger crashed and wanted to tell Microsoft about it.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Jun 2008 01:06:08 GMT</pubDate>
    <dc:creator>dkelly</dc:creator>
    <dc:date>2008-06-20T01:06:08Z</dc:date>
    <item>
      <title>help with technical note TN228 CW5.7 9s08RE16</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187845#M6623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have been looking for a way to write to FLASH by transferring code to RAM and running from there. I have found TN228 which covers my needs nicely. However I have the following questions:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&amp;nbsp; The copy routine to copy from ROM to RAM goes&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char *srsPtr, *dstPtr;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int count;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; srcPtr = (char *)Start_Copy_In_RAM;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dstPtr = (char *)&amp;amp;func;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //produces error "Non standard conversion used"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(count&amp;nbsp; = 0; count &amp;lt; (int) Size_Copy_In_RAM; count++;dstPtr++;srcPtr++)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; *dstPtr = *srcPtr;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;"func" is the name of the function to be copied across&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why the error here?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. The note details "Start_In_ROM refers to the beginning of the segment...."&amp;nbsp; There is no mention in the code of this name. Is this a typo error.(You will have had to have read the TN to understand this)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The note says it is valid for linker V5.0.19 or higher (HC08 V2.1.x or higher).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone ever used this TN?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 00:23:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187845#M6623</guid>
      <dc:creator>stevec</dc:creator>
      <dc:date>2008-02-09T00:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: help with technical note TN228 CW5.7 9s08RE16</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187846#M6624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Your code has some errors if this is the exact code you used.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;1) You defined srcPtr as srsPtr.&lt;/DIV&gt;&lt;DIV&gt;2) In the for loop you seperated the increments with a semi-colon instead of a comma.&amp;nbsp; The semi-colon only goes at the end after srcPtr++.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 03:19:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187846#M6624</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2008-02-09T03:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: help with technical note TN228 CW5.7 9s08RE16</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187847#M6625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;About the 1. point only.&lt;BR /&gt;There is no error for this line, "C1805: Non standard conversion used" is (by default) only a warning. And the warning that the ANSI standard does not cover this conversion is correct (according to the standard), but at the same time there is no real problem here too.&lt;BR /&gt;By casting first to a (void*) you can avoid the diagnostic message.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char *dstPtr;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dstPtr = (char *)(void*)&amp;amp;func;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Also the linker version is not a problem if you are not using really acient tools :smileyhappy:.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Feb 2008 04:34:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187847#M6625</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-02-09T04:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: help with technical note TN228 CW5.7 9s08RE16</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187848#M6626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Allawtterb,&lt;BR /&gt;The srsPtr was a typing error on my part.&lt;BR /&gt;&lt;BR /&gt;The 'for' loop was exactly as in the technical note, so Metroworks got that wrong.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2008 16:33:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187848#M6626</guid>
      <dc:creator>stevec</dc:creator>
      <dc:date>2008-02-11T16:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: help with technical note TN228 CW5.7 9s08RE16</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187849#M6627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Daniel,&lt;BR /&gt;&lt;BR /&gt;Thanks for that. That warning has gone away now. However more have been thrown up. I shall try sorting them, but may be back!!&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2008 16:35:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187849#M6627</guid>
      <dc:creator>stevec</dc:creator>
      <dc:date>2008-02-11T16:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: help with technical note TN228 CW5.7 9s08RE16</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187850#M6628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;HC12 rather than the O.P.'s HC08, but still the same tech note. Codewarrior is not returning the address of my function. This is mostly per TN228:&lt;BR /&gt;&lt;BR /&gt;extern UINT16 far __SEG_START_RUN_FROM_RAM[]; // source from ROM&lt;BR /&gt;extern UINT16 far __SEG_END_RUN_FROM_RAM[]; // end of ROM source&lt;BR /&gt;extern UINT16 far __SEG_SIZE_RUN_FROM_RAM[]; // size of ROM source&lt;BR /&gt;&lt;BR /&gt;#pragma MESSAGE DISABLE C12002&lt;BR /&gt;void&lt;BR /&gt;rom_to_ram( void )&lt;BR /&gt;{&lt;BR /&gt;UINT16 *far source;&lt;BR /&gt;UINT16 *dest;&lt;BR /&gt;&lt;BR /&gt;// Multiple casts to mute compiler warning&lt;BR /&gt;dest = (UINT16 *)(void *)&amp;amp;ram_updater&lt;BR /&gt;source = __SEG_START_RUN_FROM_RAM;&lt;BR /&gt;while( source __SEG_END_RUN_FROM_RAM )&lt;BR /&gt;*dest++ = *source++;&lt;BR /&gt;}&lt;BR /&gt;#pragma MESSAGE DEFAULT C12002&lt;BR /&gt;&lt;BR /&gt;ram_updater() is compiled with "#pragma CODE_SEG RUN_FROM_RAM_first" and is the only routine in RUN_FROM_RAM_first so that its address should be (confirmed, it is) the start of RUN_FROM_RAM and usable for the above copy.&lt;BR /&gt;&lt;BR /&gt;In my .prn file I have:&lt;BR /&gt;&lt;BR /&gt;SEGMENTS&lt;BR /&gt;// Stuff that must run from RAM to update FLASH&lt;BR /&gt;ROM_IMAGE = READ_ONLY 0x3d9000 TO 0x3dbffd RELOCATE_TO 0x2000;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;PLACEMENT&lt;BR /&gt;RUN_FROM_RAM_first,&lt;BR /&gt;RUN_FROM_RAM INTO ROM_IMAGE;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Disassembly of the above address assignment:&lt;BR /&gt;355: // Multiple casts to mute compiler warning&lt;BR /&gt;356: dest = (UINT16 *)(void *)&amp;amp;ram_updater&lt;BR /&gt;0002 cc0000 [2] LDD #LOW_PAGE(ram_updater)&lt;BR /&gt;0005 6c83 [2] STD 3,SP&lt;BR /&gt;&lt;BR /&gt;Viewing the above loaded on my target in "True-Time Simulator &amp;amp; Real Time Debugger" shows LDD #0 but when ram_updater is actually called its CALL 0x2000,0x00 as expected.&lt;BR /&gt;&lt;BR /&gt;Have tried every variation on the syntax of the address assignment and not hit on one that works.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2008 20:43:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187850#M6628</guid>
      <dc:creator>dkelly</dc:creator>
      <dc:date>2008-06-19T20:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: help with technical note TN228 CW5.7 9s08RE16</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187851#M6629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Is the issue that you get a unexpected address for ram_updater?&lt;BR /&gt;For the S12 (which device are you using (HC12, S12, S12X, ...?)) the address of a far function has a different byte ordering than the address of a far data pointer, check the manual.&lt;BR /&gt;If that is the issue, and ram_updater is only executed from non paged, then marking it as __near (while still allocating it paged on flash, non paged at runtime) should help.&lt;BR /&gt;Also the declaration of ram_updater and the pragma it is allocated with may help.&lt;BR /&gt;Which memory model?&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2008 21:54:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187851#M6629</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-06-19T21:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: help with technical note TN228 CW5.7 9s08RE16</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187852#M6630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;1) Yes, 0x0000 is an unexpected address. 0x2000 is expected.&lt;BR /&gt;&lt;BR /&gt;2) 9S12NE64, banked memory model.&lt;BR /&gt;&lt;BR /&gt;3) Yes, ram_updater() is using the default far.&lt;BR /&gt;&lt;BR /&gt;Have tried putting the calling routine in #pragma CODE_SEG NON_BANKED same as my interrupt service routines but am getting C3801 complaints. Just how do I determine what attributes the compiler thinks are different?&lt;BR /&gt;&lt;BR /&gt;Once Upon A Time I found documentation in the online help on the difference in byte orders for far objects. Believe there were example macros for converting. Can't find that now.&lt;BR /&gt;&lt;BR /&gt;For lack of the above macros I thought to try something else. Created a big union for plucking parts out of a value:&lt;BR /&gt;&lt;BR /&gt;typedef union {&lt;BR /&gt;&lt;BR /&gt;struct {&lt;BR /&gt;UINT08 a, b, c, d;&lt;BR /&gt;} bytes;&lt;BR /&gt;&lt;BR /&gt;struct {&lt;BR /&gt;UINT08 a;&lt;BR /&gt;UINT16 bc;&lt;BR /&gt;UINT08 d;&lt;BR /&gt;} mixed;&lt;BR /&gt;&lt;BR /&gt;struct {&lt;BR /&gt;UINT16 ab, cd;&lt;BR /&gt;} words;&lt;BR /&gt;&lt;BR /&gt;UINT32 u32;&lt;BR /&gt;&lt;BR /&gt;} FAR_EXPERIMENT;&lt;BR /&gt;&lt;BR /&gt;And now the disassembly looks correct:&lt;BR /&gt;&lt;BR /&gt;373: UINT16 *far source;&lt;BR /&gt;374: UINT16 *dest;&lt;BR /&gt;375: FAR_EXPERIMENT addr;&lt;BR /&gt;376:&lt;BR /&gt;377: addr.u32 = (UINT32)&amp;amp;ram_updater&lt;BR /&gt;0002 cc0000 [2] LDD #ram_updater&lt;BR /&gt;378:&lt;BR /&gt;379: // Multiple casts to mute compiler warning&lt;BR /&gt;380: dest = (UINT16*)addr.words.cd;&lt;BR /&gt;0005 6c83 [2] STD 3,SP&lt;BR /&gt;&lt;BR /&gt;Which prompted me to try a similar reduced version:&lt;BR /&gt;&lt;BR /&gt;dest = (UINT16*)((UINT32)&amp;amp;ram_updater);&lt;BR /&gt;&lt;BR /&gt;which I tried before my first post and for some reason didn't believe it worked. Am using the same trick somewhere else, upcasting to UINT32 before pulling it back down into something smaller. IIRC am using it elsewhere because it locally mutes the "loss of precision" warning in a situation that loss of precision is exactly what I wanted but for some reason was too lazy to do the union/struct thing above.&lt;BR /&gt;&lt;BR /&gt;Next: figure out what I have to do to debug code that has been relocated to RAM. First attempt the debugger crashed and wanted to tell Microsoft about it.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jun 2008 01:06:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/help-with-technical-note-TN228-CW5-7-9s08RE16/m-p/187852#M6630</guid>
      <dc:creator>dkelly</dc:creator>
      <dc:date>2008-06-20T01:06:08Z</dc:date>
    </item>
  </channel>
</rss>

