<?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>topic Re: How to prevent automatic initialization of variables? in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263982#M8384</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the start-up routine used by the Freescale toolchain is located in the CodeWarrior directory (see &amp;lt;CW&amp;gt;\MCU\ARM_EABI_Support\ewl\EWL_Runtime\Runtime_ARM\Source, startup.c and ROMCopy.c). Normally your projects use the precompiled libs (ewl\lib) which are automatically included by the compiler. If you need to change to init routine you have to prevent the inclusion of the library and add the needed parts from the described CW directory.&lt;/P&gt;&lt;P&gt;Copying is done in ROM_copy.c using the table S_romp defined in the lcf file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you sure that your variables are placed inside the MRAM section as from your lcf file it looks like only the variables placed in main_application_data will be initialized (definition of S_ROMP at end of file)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Aug 2013 08:15:06 GMT</pubDate>
    <dc:creator>thomasgrieger</dc:creator>
    <dc:date>2013-08-21T08:15:06Z</dc:date>
    <item>
      <title>How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263979#M8381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using MRAM for non-volatile storage. I define a section and locate it in MRAM.&amp;nbsp; I place c variables in that section. I would like to prevent the automatic initialization of these variables.&amp;nbsp; I there a way to do that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 20:32:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263979#M8381</guid>
      <dc:creator>stanschultz</dc:creator>
      <dc:date>2013-08-19T20:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263980#M8382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variable initialization process is tool chain dependent and usually is divided in 2 sections:&lt;/P&gt;&lt;P&gt;- BSS: variables not initialized or zero initialized. In this case, the memory is set to zeros&lt;/P&gt;&lt;P&gt;- Data: initialized variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On your toolchain startup code, you should find functions that makes the memory zero fill for BSS and the copy from Flash to RAM for Data. In the case of CW with GCC compiler, these can be found on "__arm_start.c" file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, the code there will only apply to memory sections specified to store bss and data on the linker file, here an example from LCF of CW 10.4 with GCC compiler:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13769533611886644" jivemacro_uid="_13769533611886644" modifiedtitle="true"&gt;
&lt;P&gt;/* Initialized data sections goes into RAM, load LMA copy after code */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; .data : AT(___ROM_AT)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _sdata = .;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* create a global symbol at data start */&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt;&amp;nbsp;&amp;nbsp; *(.data)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* .data sections */&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.data*)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* .data* sections */&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _edata = .;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* define a global symbol at data end */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; } &amp;gt; m_data&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; ___data_size = _edata - _sdata;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* Uninitialized data section */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; . = ALIGN(4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; .bss :&lt;/P&gt;
&lt;P&gt;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* This is used by the startup in order to initialize the .bss section */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __START_BSS = .;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PROVIDE ( __bss_start__ = __START_BSS );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.bss)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.bss*)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *(COMMON)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; . = ALIGN(4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __END_BSS = .;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PROVIDE ( __bss_end__ = __END_BSS );&lt;/P&gt;
&lt;P&gt;&amp;nbsp; } &amp;gt; m_data&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see, there are two sections, .data and .bss using linker such as *(.bss) and *(.data) will make the linker to place all bss on .bss memory section and all .data on .data section. ONLY what is placed here will be take by the startup functions for zero fill and copy from flash to RAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your linker file define the MRAM section to be filled by .bss or .data then you would need to manually discard those by tweaking the start up code. If your MRAM section does not request to be filled with .bss or .data then the startup code is not touching this section, which means there is no variable initialization.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Carlos Neri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 23:10:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263980#M8382</guid>
      <dc:creator>carlos_neri</dc:creator>
      <dc:date>2013-08-19T23:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263981#M8383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Carlos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your comments were helpful but I still haven’t come up with a solution.  I’m using the Freescale toolsuite (not GCC) since I’m using MQX.  I’m having a difficult time finding the routine that is equivalent to __arm_start.c.  I attached my lcf file for your information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2013 19:29:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263981#M8383</guid>
      <dc:creator>stanschultz</dc:creator>
      <dc:date>2013-08-20T19:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263982#M8384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the start-up routine used by the Freescale toolchain is located in the CodeWarrior directory (see &amp;lt;CW&amp;gt;\MCU\ARM_EABI_Support\ewl\EWL_Runtime\Runtime_ARM\Source, startup.c and ROMCopy.c). Normally your projects use the precompiled libs (ewl\lib) which are automatically included by the compiler. If you need to change to init routine you have to prevent the inclusion of the library and add the needed parts from the described CW directory.&lt;/P&gt;&lt;P&gt;Copying is done in ROM_copy.c using the table S_romp defined in the lcf file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you sure that your variables are placed inside the MRAM section as from your lcf file it looks like only the variables placed in main_application_data will be initialized (definition of S_ROMP at end of file)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2013 08:15:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263982#M8384</guid>
      <dc:creator>thomasgrieger</dc:creator>
      <dc:date>2013-08-21T08:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263983#M8385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thomas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your response.  Yes, my variables are in the MRAM.  I attached a partial listing of the map file to show you that yes there are included.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also found the ROMCopy.c and included that file in my project.  I then rebuilt my project and searched the link map file to make sure my copy was the one included.  I then put breakpoints in ROMCopy and verified that nothing was being copied to MRAM.  My program runs correctly but I have to explicitly initialize all my MRAM variables every run.  It looks to me like something is initializing MRAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2013 19:19:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263983#M8385</guid>
      <dc:creator>stanschultz</dc:creator>
      <dc:date>2013-08-21T19:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263984#M8386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;all the variables on the map file you sent are zero initialized? or how do you expected them on the memory?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2013 21:43:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263984#M8386</guid>
      <dc:creator>carlos_neri</dc:creator>
      <dc:date>2013-08-21T21:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263985#M8387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a  flag variable in MRAM that indicates whether the variables have been initialized.  If the flag variable is not equal to a unique fixed constant, my software calls a routine to initialize the MRAM variables and then sets the flag variable to that unique fixed constant.  On subsequent resets, I expect the flag variable to still be that unique fixed constant and the rest of my MRAM variables contain the last values that were written to them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2013 21:54:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263985#M8387</guid>
      <dc:creator>stanschultz</dc:creator>
      <dc:date>2013-08-21T21:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263986#M8388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the expectation makes sense, being MRAM non-volatile, that variable shouldn't change.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would then look for any code that does a copy on buffers on your MRAM? I'm thinking that perhaps a pointer runaway is overwriting that exact variable or the MRAM entirely?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 17:16:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263986#M8388</guid>
      <dc:creator>carlos_neri</dc:creator>
      <dc:date>2013-08-22T17:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263987#M8389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Carlos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your suggestion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following is a much simpler program.&amp;nbsp; When I break at the if statement the value of initFlag and temp2 is 8.&amp;nbsp; The value of temp is INIT_VALUE and the value of temp1 is 12.&amp;nbsp; When I then break at mqx_exit, the value of initFlag is INIT_VALUE.&amp;nbsp; The other variables haven’t changed.&amp;nbsp; I then restart the program and get the exact same results.&amp;nbsp; The address of initFlag is 0x60000000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/****************************************************************************&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI type="ul"&gt;&lt;P&gt;&amp;nbsp; This file contains MQX only stationery code.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;****************************************************************************/&lt;/P&gt;&lt;P&gt;#include "main.h"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;typedef volatile unsigned int VUINT32;&lt;/P&gt;&lt;P&gt;#define INIT_VALUE 0x5a3ca5c3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#pragma define_section myNonVol ".myNonVol" far_abs RW&lt;/P&gt;&lt;P&gt;#pragma section myNonVol begin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VUINT32 initFlag;&lt;/P&gt;&lt;P&gt;#pragma section myNonVol end&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VUINT32 temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VUINT32 temp1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VUINT32 temp2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TASK_TEMPLATE_STRUCT MQX_template_list[] =&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;/*&amp;nbsp; Task number, Entry point, Stack, Pri, String, Auto? */&lt;/P&gt;&lt;P&gt;&amp;nbsp; {MAIN_TASK,&amp;nbsp; Main_task,&amp;nbsp; 1500,&amp;nbsp; 9,&amp;nbsp; "main", MQX_AUTO_START_TASK},&lt;/P&gt;&lt;P&gt;&amp;nbsp; {0,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&amp;nbsp; 0,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0,&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; }&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/&lt;STRONG&gt;TASK&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;void Main_task(uint_32 initial_data)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; temp = *(VUINT32*)(0x60040000);&lt;BR /&gt; temp1 = *(VUINT32*)(0x60060000);&lt;BR /&gt; temp2 = initFlag;&lt;BR /&gt; &lt;BR /&gt; if (initFlag !=INIT_VALUE)&lt;BR /&gt; {&lt;BR /&gt;&amp;nbsp; *(VUINT32*)(0x60040000) = INIT_VALUE;&lt;BR /&gt;&amp;nbsp; *(VUINT32*)(0x60060000) = 12;//INIT_VALUE;&lt;BR /&gt;&amp;nbsp; temp1 = *(VUINT32*)(0x60060000);&lt;BR /&gt;&amp;nbsp; initFlag = INIT_VALUE;&lt;BR /&gt; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; _mqx_exit(0);&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 19:43:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263987#M8389</guid>
      <dc:creator>stanschultz</dc:creator>
      <dc:date>2013-08-22T19:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263988#M8390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Stan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MQX initialization code setup GPIOs and Flexbus for every project, you can see this in init_hw.c. After this, __copy_rom_sections_to_ram() is executed, this function copies all data from flash to RAM (or MRAM in this case) and after this it jumps to the main application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As your flag is a variable linked in MRAM __copy_rom_sections_to_ram() is causing you to loose your data as it reloads the default value before you can read the flag status. You can avoid this by creating a new section in the linker file and placing your variable here, this way, __copy_rom_sections_to_ram() will not be aware of this variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another workaround would be not to use a variable, just write to an MRAM address that you know and is not used in your application, this way you can read a known value from this address and determine if you need to initialize your data or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Carlos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 17:07:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263988#M8390</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2013-08-29T17:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263989#M8391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Carlos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That’s what my code does, it puts the variable initFlag in a new section labeled myNonVol.  I then created the section in the link control file (see attached file).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 19:14:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263989#M8391</guid>
      <dc:creator>stanschultz</dc:creator>
      <dc:date>2013-08-29T19:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to prevent automatic initialization of variables?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263990#M8392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It turns out my code, linker file, etc. was correct and there really wan't any automatic initialization of the variables in MRAM.&amp;nbsp; I found out (with Freescale's help) that MRAM should be located in a non-cacheable page (i.e. 0xa0000000).&amp;nbsp; When I did this everything worked as expected.&amp;nbsp; I originally had MRAM located at 0x60000000 which is a cacheable page.&amp;nbsp; When my program wrote to this address the value was going into cache memory and not to the MRAM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Oct 2013 13:22:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-prevent-automatic-initialization-of-variables/m-p/263990#M8392</guid>
      <dc:creator>stanschultz</dc:creator>
      <dc:date>2013-10-09T13:22:25Z</dc:date>
    </item>
  </channel>
</rss>

