<?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: [D-Flash] How to set initial value in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/D-Flash-How-to-set-initial-value/m-p/164534#M5303</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi kef,&lt;/P&gt;&lt;P&gt;Thanks a lot. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pogo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Sep 2011 08:13:04 GMT</pubDate>
    <dc:creator>Pogo</dc:creator>
    <dc:date>2011-09-05T08:13:04Z</dc:date>
    <item>
      <title>[D-Flash] How to set initial value</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/D-Flash-How-to-set-initial-value/m-p/164532#M5301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to set a const variable with initial value in D-Flash segment and use this variable in some funtion. But if I set this variable with initial value and use it in other function. When I change this variable using writing D-Flash with user's input, this variable will not change. I checked the complier code, all code which using this variable will replace by the initial value. The following example code will express my issue.&lt;/P&gt;&lt;PRE&gt;#pragma DATA_SEG __EPAGE MYDFlashconst unsinged int uVariable = 10;#pragma DATA_SEG DEFAULTvoid main(void){&amp;nbsp;&amp;nbsp; if( uVariable == 10 )&amp;nbsp; //&amp;lt;-- this line complier will not use uVariable, it will use 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("OK");&amp;nbsp;&amp;nbsp; WriterToDFlash();&amp;nbsp;&amp;nbsp; if( uVariable == 5 )&amp;nbsp; // same above&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("ok");&amp;nbsp;&amp;nbsp; else&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("write to D-flash failed");}void WriteToDFlash(){&amp;nbsp;&amp;nbsp; //Write 5 to uVarialbe's address}&lt;/PRE&gt;&lt;P&gt;The run result will be&lt;/P&gt;&lt;P&gt;OK&lt;/P&gt;&lt;P&gt;write to D-flash failed.&lt;/P&gt;&lt;P&gt;My expection is OK and OK.&lt;/P&gt;&lt;P&gt;My question is how can I tell to complier don't using const value to replace variable and just use the value in varible's address. Please help me! Thanks a lot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pogo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:11:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/D-Flash-How-to-set-initial-value/m-p/164532#M5301</guid>
      <dc:creator>Pogo</dc:creator>
      <dc:date>2020-10-29T09:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: [D-Flash] How to set initial value</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/D-Flash-How-to-set-initial-value/m-p/164533#M5302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand your request&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) use volatile keyword, like volatile const int var;&lt;/P&gt;&lt;P&gt;2) Go to compiler options and check "Disable CONST variable by constant replacement" optimization.&lt;/P&gt;&lt;P&gt;3) move variable definition to different source file.&amp;nbsp;When compiling different source files, where variable is just declared, compiler won't see&amp;nbsp;variable initializer and won't replace variable&amp;nbsp;access with constant.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Sep 2011 00:00:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/D-Flash-How-to-set-initial-value/m-p/164533#M5302</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-09-05T00:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: [D-Flash] How to set initial value</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/D-Flash-How-to-set-initial-value/m-p/164534#M5303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi kef,&lt;/P&gt;&lt;P&gt;Thanks a lot. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pogo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Sep 2011 08:13:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/D-Flash-How-to-set-initial-value/m-p/164534#M5303</guid>
      <dc:creator>Pogo</dc:creator>
      <dc:date>2011-09-05T08:13:04Z</dc:date>
    </item>
  </channel>
</rss>

