<?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>LPCXpresso IDE中的主题 Re: Do not init global variable</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565542#M18062</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rkiryanov on Mon Apr 26 21:27:37 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: CodeRedSupport&lt;/STRONG&gt;&lt;BR /&gt;What is it you are trying to achieve, and why?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I mark with __no_init my OS state variables, I init them before all other variables (zero init and value init). Also, IAR help:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;Description &lt;BR /&gt;Use the __no_init keyword to place a data object in non-volatile memory. This means that the initialization of the variable, for example at system startup, is suppressed.&lt;/SPAN&gt;&lt;HR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 02:15:59 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T02:15:59Z</dc:date>
    <item>
      <title>Do not init global variable</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565539#M18059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rkiryanov on Mon Apr 26 11:34:35 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in IAR projects I use __no_init for some variables, this keyword tells compiler that initialization must be suppressed. How can I do this in LPCXpresso?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:15:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565539#M18059</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Do not init global variable</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565540#M18060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by brucesegal on Mon Apr 26 13:04:32 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you use the gcc attribute to put the variable in a different section that&amp;nbsp; is not initialized? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;uint32_ttestForSection&amp;nbsp; __attribute__ ((section ("_edata")));&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe this will link the testForSection global into the _edata section, which should be at the end of _data (initialized globals) and before _bss (zeroed globals)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess you could also create your own section and modify the .ld files that are used by the ide when compiling. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not tested but the idea may fly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:15:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565540#M18060</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Do not init global variable</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565541#M18061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Mon Apr 26 13:15:30 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is it you are trying to achieve, and why? I don't know what the IAR tools do, so you need to explain why you need this. We can then suggest a way you can achieve it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:15:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565541#M18061</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: Do not init global variable</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565542#M18062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rkiryanov on Mon Apr 26 21:27:37 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: CodeRedSupport&lt;/STRONG&gt;&lt;BR /&gt;What is it you are trying to achieve, and why?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I mark with __no_init my OS state variables, I init them before all other variables (zero init and value init). Also, IAR help:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;Description &lt;BR /&gt;Use the __no_init keyword to place a data object in non-volatile memory. This means that the initialization of the variable, for example at system startup, is suppressed.&lt;/SPAN&gt;&lt;HR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:15:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565542#M18062</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Do not init global variable</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565543#M18063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Mon Apr 26 22:24:34 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I am confused... Surely non-volatile memory is flash? Which isn't a good place to be putting variables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, variables are either initialised with a value (.data), or initialised with zero (.bss). This is done in the startup code. Is there any particular reason why this is a problem? If it is, you can modify the startup code to either not perform the initialization, or you can add code to initialise them to the values you need.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:15:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565543#M18063</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Do not init global variable</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565544#M18064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rkiryanov on Mon Apr 26 23:24:37 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: CodeRedSupport&lt;/STRONG&gt;&lt;BR /&gt;Surely non-volatile&amp;nbsp; memory is flash?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Battery powered SRAM too (see LPC23xx). For example, variable that should not be modified on reset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: CodeRedSupport&lt;/STRONG&gt;&lt;BR /&gt;This is done in the startup code. Is there any particular reason why this is a problem?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Problems:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Order of initialization.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;void ResetISR(void)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; hw::Init();
&amp;nbsp;&amp;nbsp;&amp;nbsp; OS::Init();
&amp;nbsp;&amp;nbsp;&amp;nbsp; .bss init&amp;nbsp; // will overwrite OS variables
&amp;nbsp;&amp;nbsp;&amp;nbsp; .data init // will overwrite OS variables
&amp;nbsp;&amp;nbsp;&amp;nbsp; call C++ objects ctors
&amp;nbsp;&amp;nbsp;&amp;nbsp; etc
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Twice initialization.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;void ResetISR(void)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; hw::Init();
&amp;nbsp;&amp;nbsp;&amp;nbsp; .bss init
&amp;nbsp;&amp;nbsp;&amp;nbsp; .data init
&amp;nbsp;&amp;nbsp;&amp;nbsp; OS::Init(); // overwrite some .bss, looks displeasingly
&amp;nbsp;&amp;nbsp;&amp;nbsp; call C++ objects ctors
&amp;nbsp;&amp;nbsp;&amp;nbsp; etc
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Value of the initialization, this code cannot be replaced.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (size_t i = 0; i &amp;lt; max_threads_count; ++i)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os_free_threads&lt;I&gt; = i;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:16:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565544#M18064</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Do not init global variable</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565545#M18065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Tue Apr 27 06:58:32 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;As suggested by brucesegal, you need to use the section attribute when declaring your variable(s). I suggest using a section name that suggests what it is being used for...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;int noinit_var&amp;nbsp; __attribute__ ((section (".noinit")));&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;SPAN&gt;By default this will get placed between the .data and .bss sections. But because the code red startup code is unaware of its existence, it will not get initialised by software.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You will need to create your own linker script file to place it at the address of your actual battery backed RAM. Information on creating your own linker scripts can be found (login required) at:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://" rel="nofollow noopener noreferrer" target="_blank"&gt;http://lpcxpresso.code-red-tech.com/LPCXpresso/node/31&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:16:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Do-not-init-global-variable/m-p/565545#M18065</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T02:16:00Z</dc:date>
    </item>
  </channel>
</rss>

