<?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: Trouble placing variables at specific locations in memory</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-placing-variables-at-specific-locations-in-memory/m-p/233221#M9177</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ANSI C there is no guarantee at all that the variables will be allocated in the sequence in which they are defined,&lt;/P&gt;&lt;P&gt;The linker can decide to allocate them in any order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need the different values to be allocated in a specific sequence, you can define them in a structure and then access the various fields inside of the structure using macros.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;__declspecc(version ) const struct {&lt;/P&gt;&lt;P&gt;&amp;nbsp; UI16 major;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UI16 minor;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UI16 build;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UI16 revision&lt;/P&gt;&lt;P&gt;} fw_version_nbr = {SOFTWARE_VERSION_MAJOR, SOFTWARE_VERSION_MINOR, SOFTWARE_VERSION_BUILD, SOFTWARE_VERSION_REVISION};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define fwMajor fw_version_nbr.major&lt;/P&gt;&lt;P&gt;#define fwMinor fw_version_nbr.minor&lt;/P&gt;&lt;P&gt;#define fwBuild fw_version_nbr.build&lt;/P&gt;&lt;P&gt;#define fwRevision fw_version_nbr.revision&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should be equivalent and should keep the existing code compatible,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Jan 2013 06:48:13 GMT</pubDate>
    <dc:creator>CrasyCat</dc:creator>
    <dc:date>2013-01-23T06:48:13Z</dc:date>
    <item>
      <title>Trouble placing variables at specific locations in memory</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-placing-variables-at-specific-locations-in-memory/m-p/233220#M9176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using CW 10.2,&amp;nbsp; I've figured out how to create and locate a "section" in order to place variables,&amp;nbsp; as such ...&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;STRONG&gt;#pragma&lt;/STRONG&gt; force_active on&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;STRONG&gt;#pragma&lt;/STRONG&gt; define_section version ".version" far_abs R &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;STRONG&gt;#pragma&lt;/STRONG&gt; section version begin&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN style="color: #3366ff;"&gt; &lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;STRONG&gt;__declspec&lt;/STRONG&gt;( version ) &lt;STRONG&gt;const&lt;/STRONG&gt; &lt;STRONG&gt;U16&lt;/STRONG&gt; &lt;EM&gt;fwMajor&lt;/EM&gt; = SOFTWARE_VERSION_MAJOR;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;STRONG&gt;__declspec&lt;/STRONG&gt;( version )&amp;nbsp; &lt;STRONG&gt;const&lt;/STRONG&gt; &lt;STRONG&gt;U16&lt;/STRONG&gt; &lt;EM&gt;fwMinor&lt;/EM&gt; = SOFTWARE_VERSION_MINOR;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;STRONG&gt;__declspec&lt;/STRONG&gt;( version )&amp;nbsp; &lt;STRONG&gt;const&lt;/STRONG&gt; &lt;STRONG&gt;U16&lt;/STRONG&gt; &lt;EM&gt;fwBuild&lt;/EM&gt; = SOFTWARE_VERSION_BUILD;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;STRONG&gt;__declspec&lt;/STRONG&gt;( version )&amp;nbsp; &lt;STRONG&gt;const&lt;/STRONG&gt; &lt;STRONG&gt;U16&lt;/STRONG&gt; &lt;EM&gt;fwRevision&lt;/EM&gt; = SOFTWARE_VERSION_REVISION;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;STRONG&gt;#pragma&lt;/STRONG&gt; section version end&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;When I inspect the MAP file, the constants are placed where expected ( as defined in my LCF file ).&amp;nbsp;&amp;nbsp; The &lt;EM&gt;order&lt;/EM&gt; of the constants, however, is not the same order as they appear in their declaration.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;Question:&amp;nbsp; Is there another pragma or attribute that can be used to keep the order of variables within a section the same as their declaration order ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;R.W.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 18:36:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-placing-variables-at-specific-locations-in-memory/m-p/233220#M9176</guid>
      <dc:creator>RWey</dc:creator>
      <dc:date>2013-01-22T18:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble placing variables at specific locations in memory</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-placing-variables-at-specific-locations-in-memory/m-p/233221#M9177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ANSI C there is no guarantee at all that the variables will be allocated in the sequence in which they are defined,&lt;/P&gt;&lt;P&gt;The linker can decide to allocate them in any order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need the different values to be allocated in a specific sequence, you can define them in a structure and then access the various fields inside of the structure using macros.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;__declspecc(version ) const struct {&lt;/P&gt;&lt;P&gt;&amp;nbsp; UI16 major;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UI16 minor;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UI16 build;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UI16 revision&lt;/P&gt;&lt;P&gt;} fw_version_nbr = {SOFTWARE_VERSION_MAJOR, SOFTWARE_VERSION_MINOR, SOFTWARE_VERSION_BUILD, SOFTWARE_VERSION_REVISION};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define fwMajor fw_version_nbr.major&lt;/P&gt;&lt;P&gt;#define fwMinor fw_version_nbr.minor&lt;/P&gt;&lt;P&gt;#define fwBuild fw_version_nbr.build&lt;/P&gt;&lt;P&gt;#define fwRevision fw_version_nbr.revision&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should be equivalent and should keep the existing code compatible,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jan 2013 06:48:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-placing-variables-at-specific-locations-in-memory/m-p/233221#M9177</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2013-01-23T06:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble placing variables at specific locations in memory</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-placing-variables-at-specific-locations-in-memory/m-p/233222#M9178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I was thinking a structure might be the only way, and after changing it to that method, it will work.&amp;nbsp; I was just wondering if there was some sort of "Order" pragma.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A structure it is.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jan 2013 16:16:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Trouble-placing-variables-at-specific-locations-in-memory/m-p/233222#M9178</guid>
      <dc:creator>RWey</dc:creator>
      <dc:date>2013-01-23T16:16:49Z</dc:date>
    </item>
  </channel>
</rss>

