<?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: Strings going to SRAM</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Strings-going-to-SRAM/m-p/475325#M11928</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The most probably you didn't put &lt;STRONG&gt;const&lt;/STRONG&gt; in front of the string defined:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;const char mystring[] = "Hello";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the &lt;STRONG&gt;const&lt;/STRONG&gt;, constant string can be allocated to Flash, otherwise it will be distributed to RAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you can use us #pragma declaration define a segment (constant, data, code) and still '&lt;STRONG&gt;const&lt;/STRONG&gt;' is necessary&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax:&amp;nbsp; #pragma CONST_SEG &amp;lt;name&amp;gt;|DEFAULT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This segment must be explicitly allocated within the PLACEMENT block in the link parameter file. For more information, refer to the chapter Linker Issues of the Build Tools Utilities reference manual.&lt;/P&gt;&lt;P&gt;The following listing exemplifies the correct usage of the &lt;SAMP class="codeph"&gt;CONST_SEG&lt;/SAMP&gt;pragma:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;/* p.h */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;#pragma CONST_SEG MY_ROM&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;extern const int cx;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;#pragma CONST_SEG DEFAULT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;extern const int y;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;/* p.c */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;#pragma CONST_SEG MY_RAM&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;const int cx = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;#pragma CONST_SEG DEFAULT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;const int cy = 2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;/* main.c */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;#include "p.h"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;void main(void)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;{&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;s = cx + cy;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Find more info in CodeWarrior Help by searching "S12Z Pragmas".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;iggi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Jun 2016 09:31:46 GMT</pubDate>
    <dc:creator>iggi</dc:creator>
    <dc:date>2016-06-03T09:31:46Z</dc:date>
    <item>
      <title>Strings going to SRAM</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Strings-going-to-SRAM/m-p/475324#M11927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are using S12ZVMC128 MCU. &lt;/P&gt;&lt;P&gt;All string constants declared in the application code get assigned to SRAM by the compiler. As per what we have read constant strings should be in Flash RAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What settings have to be changed / declaration made to avoid this ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jun 2016 18:48:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Strings-going-to-SRAM/m-p/475324#M11927</guid>
      <dc:creator>manishsangram</dc:creator>
      <dc:date>2016-06-02T18:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Strings going to SRAM</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Strings-going-to-SRAM/m-p/475325#M11928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The most probably you didn't put &lt;STRONG&gt;const&lt;/STRONG&gt; in front of the string defined:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;const char mystring[] = "Hello";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the &lt;STRONG&gt;const&lt;/STRONG&gt;, constant string can be allocated to Flash, otherwise it will be distributed to RAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you can use us #pragma declaration define a segment (constant, data, code) and still '&lt;STRONG&gt;const&lt;/STRONG&gt;' is necessary&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax:&amp;nbsp; #pragma CONST_SEG &amp;lt;name&amp;gt;|DEFAULT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This segment must be explicitly allocated within the PLACEMENT block in the link parameter file. For more information, refer to the chapter Linker Issues of the Build Tools Utilities reference manual.&lt;/P&gt;&lt;P&gt;The following listing exemplifies the correct usage of the &lt;SAMP class="codeph"&gt;CONST_SEG&lt;/SAMP&gt;pragma:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;/* p.h */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;#pragma CONST_SEG MY_ROM&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;extern const int cx;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;#pragma CONST_SEG DEFAULT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;extern const int y;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;/* p.c */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;#pragma CONST_SEG MY_RAM&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;const int cx = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;#pragma CONST_SEG DEFAULT&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;const int cy = 2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;/* main.c */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;#include "p.h"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;void main(void)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;{&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;s = cx + cy;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Find more info in CodeWarrior Help by searching "S12Z Pragmas".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;iggi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2016 09:31:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Strings-going-to-SRAM/m-p/475325#M11928</guid>
      <dc:creator>iggi</dc:creator>
      <dc:date>2016-06-03T09:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Strings going to SRAM</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Strings-going-to-SRAM/m-p/475326#M11929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello iggi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Our usage of strings are more inline, meaning we are not declaring string constants at all but directly using them. For example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sprintf("Hello World");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why would the above string go to RAM ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2016 11:49:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Strings-going-to-SRAM/m-p/475326#M11929</guid>
      <dc:creator>manishsangram</dc:creator>
      <dc:date>2016-06-03T11:49:49Z</dc:date>
    </item>
  </channel>
</rss>

