<?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>8-bit Microcontrollers中的主题 Re: Const Variables</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138895#M5141</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Usages by pointer (by name) are still usages. As long a function is referred to anywhere it should get linked. The only case linking would not happen automatically is if the numerical address is used to call functions (or to refer to objects in general),&lt;/P&gt;&lt;P&gt;e.g. Calls like ((void(*)())0xF000)()&lt;/P&gt;&lt;P&gt;wont cause a function located at 0xF000 to be linked.&lt;/P&gt;&lt;P&gt;But with this setup, the hard part is to make sure the numbers are all correct, and not to list the function in the prm.&lt;/P&gt;&lt;P&gt;In case all addresses are offsets into a global table (function pointer array) then listing the name of that table in the prm ENTRIES is all that is needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Apr 2009 02:49:11 GMT</pubDate>
    <dc:creator>CompilerGuru</dc:creator>
    <dc:date>2009-04-21T02:49:11Z</dc:date>
    <item>
      <title>Const Variables</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138887#M5133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;I'm trying to allocate const variables in ROM on my HCS08GT32. I've tried with "-Cc" option, but it doesn't work: the variables remain in the RAM. What's the best way to allocate variables in ROM?&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;DIV&gt;Andrew&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 15:25:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138887#M5133</guid>
      <dc:creator>Andrew</dc:creator>
      <dc:date>2006-06-08T15:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Const Variables</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138888#M5134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;Are you using CodeWarrior compiler?&lt;/P&gt;&lt;P&gt;Normally you just have to define your constant as constants using const keyword.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;const int version= 0x34;&lt;/P&gt;&lt;P&gt;Be careful, if you want to define a constant table&amp;nbsp;of pointer to int, you have to define it as&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;int *const&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tab2[] = {0x01, 0x02, 0x03, 0x04};&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;I hope this helps.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 17:06:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138888#M5134</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-06-08T17:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Const Variables</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138889#M5135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Yes,&lt;/DIV&gt;&lt;DIV&gt;I'm using CW 5.0. I've defined my variables as follow:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;const unsigned int step[16]={1,1,1,1,1,1,1,3,5,9,11,16,20,29,45,60};&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I've set the "-Cc" option but it doesn't still work!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Otherwise,&lt;/DIV&gt;&lt;DIV&gt;if I write:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;const Struct_a MikeyMouse = {1,2.3}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;MikeyMouse goes to ROM!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;What's happen?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 17:30:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138889#M5135</guid>
      <dc:creator>Andrew</dc:creator>
      <dc:date>2006-06-08T17:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Const Variables</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138890#M5136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;Hum.&lt;/P&gt;&lt;P&gt;canst unsigned into step[16]={1,1,1,1,1,1,1,3,5,9,11,16,20,29,45,60}; should go to ROAM.&lt;/P&gt;&lt;P&gt;Do you have a pragma DATA_SEG in front of it?&lt;/P&gt;&lt;P&gt;an you try to add #pragma DATA_SEG DEFAULT prior to constant definition.&lt;/P&gt;&lt;P&gt;Is it&amp;nbsp;working better?&lt;/P&gt;&lt;P&gt;-cc will not help as it is ignore in ELF DWARF file format. It is a legacy option for an older release of the tools.&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 18:04:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138890#M5136</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2006-06-08T18:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Const Variables - QE128</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138891#M5137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Well,&lt;/DIV&gt;&lt;DIV&gt;I'm sorry but I was wrong. I was looking for an incorrect pattern of value: the data are interger so the correct pattern was 0001, 0001, ...... while I was looking for 01,01,...&lt;/DIV&gt;&lt;DIV&gt;Is not necessary use the option "-Cc" nor use #pragma directive: is it sufficient use the "const" modifier.&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;DIV&gt;Added p/n to subject.&lt;/DIV&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by NLFSJ on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-08-11&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;09:42 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 19:06:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138891#M5137</guid>
      <dc:creator>Andrew</dc:creator>
      <dc:date>2006-06-08T19:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Const Variables</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138892#M5138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys&lt;/P&gt;&lt;P&gt;I´m facing this problem right now using a QE128 in CW6.0 pro (C++).&lt;/P&gt;&lt;P&gt;I have used "const" (when in C) to put anything in ROM, like&lt;/P&gt;&lt;P&gt;uint8 const init_table[]={1,2,3,4};&lt;/P&gt;&lt;P&gt;For my surpise ( I´ve used CW for many years...) my current design (the first in C++), wich has about 10 tables like the above, simply allocates some (major..) tables in RAM (.bss in map file).&lt;/P&gt;&lt;P&gt;I tried:&lt;/P&gt;&lt;P&gt;-Cc option = not work&lt;/P&gt;&lt;P&gt;&amp;nbsp;__far = not work&lt;/P&gt;&lt;P&gt;I don´t use any SEGMENT pragma in my application, there is, the ordinary const keyword&lt;/P&gt;&lt;P&gt;should be enough to put such tables in ROM, right?&lt;/P&gt;&lt;P&gt;I spent the weekend on it, but I lost ....&lt;/P&gt;&lt;P&gt;Some tip for me?&lt;/P&gt;&lt;P&gt;Thanks in adavnce !!&lt;/P&gt;&lt;P&gt;&amp;nbsp;Ricardo Raupp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2009 07:59:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138892#M5138</guid>
      <dc:creator>Ricardo_RauppV</dc:creator>
      <dc:date>2009-04-20T07:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: Const Variables</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138893#M5139</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;&lt;FONT color="#808080" face="arial,helvetica,sans-serif"&gt;I did a short test in C++ and got my constant table in .rodata without any trouble.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080" face="arial,helvetica,sans-serif"&gt;There is one thing that you need to know when it goes around constants and C++.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#808080" face="arial,helvetica,sans-serif"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: 'Times New Roman'"&gt;&lt;FONT size="2"&gt;&lt;FONT color="#808080" face="arial,helvetica,sans-serif"&gt;In C++, constants, which are defined in a module, but are not declared previously, are supposed to be static. An external declaration must precede the constant definition&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2009 21:29:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138893#M5139</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2009-04-20T21:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Const Variables</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138894#M5140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Crasy cat&lt;/P&gt;&lt;P&gt;a) Just 10 minutes ago I did something wich worked!!!&lt;/P&gt;&lt;P&gt;I think it has something to do with your help...that is:&lt;/P&gt;&lt;P&gt;In the begining I declared a const array ( I call tables) in a cpp file and so extern it in its such .h file.&lt;/P&gt;&lt;P&gt;Well, this was not enough to work fine..&lt;/P&gt;&lt;P&gt;So I tried to include the h file in the cpp file, although I thought it should not be needed..&lt;/P&gt;&lt;P&gt;BUT for my surprise, now everything is OK..there is..my tables (const arrays) are in ROM !!!!!&lt;/P&gt;&lt;P&gt;Is it what you mean?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;b) By the way..could help me or direct me to a post about:&lt;/P&gt;&lt;P&gt;I have many functions wich are states of state machine processor, so they are accessed only by pointers.&lt;/P&gt;&lt;P&gt;CW simply put all functions in NOT USED section.&lt;/P&gt;&lt;P&gt;The ENTRIES usage in PRM file will be very hard taks, due to a state machine based application has many many states/functions.&lt;/P&gt;&lt;P&gt;Imagine if for each new one I need to copy it into prm file?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2009 21:51:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138894#M5140</guid>
      <dc:creator>Ricardo_RauppV</dc:creator>
      <dc:date>2009-04-20T21:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Const Variables</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138895#M5141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Usages by pointer (by name) are still usages. As long a function is referred to anywhere it should get linked. The only case linking would not happen automatically is if the numerical address is used to call functions (or to refer to objects in general),&lt;/P&gt;&lt;P&gt;e.g. Calls like ((void(*)())0xF000)()&lt;/P&gt;&lt;P&gt;wont cause a function located at 0xF000 to be linked.&lt;/P&gt;&lt;P&gt;But with this setup, the hard part is to make sure the numbers are all correct, and not to list the function in the prm.&lt;/P&gt;&lt;P&gt;In case all addresses are offsets into a global table (function pointer array) then listing the name of that table in the prm ENTRIES is all that is needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2009 02:49:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138895#M5141</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2009-04-21T02:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Const Variables</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138896#M5142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;P&gt;I´m in troubles again...&lt;/P&gt;&lt;P&gt;Although I included the h file into my app file (this solved my problem earlier) it is not working now...&lt;/P&gt;&lt;P&gt;What do you mean by :&lt;/P&gt;&lt;P&gt;- module defined x previously declaration?&lt;/P&gt;&lt;P&gt;- would be a external declaration just as:&lt;/P&gt;&lt;P&gt;external str_a_t&amp;nbsp; str_a;// &amp;nbsp;in another cpp file (i.e. main.cpp)?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2009 02:50:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138896#M5142</guid>
      <dc:creator>Ricardo_RauppV</dc:creator>
      <dc:date>2009-08-11T02:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Const Variables</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138897#M5143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To solve the 'defined previously' you have to define the same segment in the header file i.e. if you use MY_SECTION in the c file, use MY SECTION in the header file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2009 05:38:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138897#M5143</guid>
      <dc:creator>CarlFST60L</dc:creator>
      <dc:date>2009-08-11T05:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Const Variables</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138898#M5144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="UserName"&gt;&lt;SPAN&gt;CarlFST60L&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="UserName"&gt;In fact the "defined previously" error was solved by adding the segment specification in the h file, as you suggested.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="UserName"&gt;Very thanks for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="UserName"&gt;Ricardo Raupp&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2009 19:35:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Const-Variables/m-p/138898#M5144</guid>
      <dc:creator>Ricardo_RauppV</dc:creator>
      <dc:date>2009-08-20T19:35:46Z</dc:date>
    </item>
  </channel>
</rss>

