<?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 K21 Flex Memory Setup in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-Flex-Memory-Setup/m-p/387753#M20928</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;I reviewed couple of posts regarding setting flex memory on Kinetis devices and so far I am still facing issues with setting the Flex memory on the MK21FX512VLQ12.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;First I am using the PE to set peripherals, using the Cpu_SetFlexNVMPartition() causes the core to lockup and reset (lockup bit in RCM_SRS1 is set) so I gave up on using this function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;I tried the following code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (FTFE_FSTAT &amp;amp; FTFE_FSTAT_ACCERR_MASK)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FSTAT = FTFE_FSTAT_ACCERR_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Write the FCCOB registers */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB0 = FTFE_FCCOB0_CCOBn(0x80); // Selects the PGMPART command&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB1 = 0x00;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB2 = 0x00;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB3 = 0x00;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* FCCOB4 is written with the code for the subsystem sizes (eeprom_size define) */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB4 = 0x18; //64bytes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* FFCOB5 is written with the code for the Dflash size (dflash_size define) */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB5 = 0x0B; //32KB for data and 96KB for EE Backup&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* All required FCCOBx registers are written, so launch the command */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (!(FTFE_FSTAT &amp;amp; FTFE_FSTAT_CCIF_MASK)){};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FSTAT = FTFE_FSTAT_CCIF_MASK;&amp;nbsp; // step in line by line after this line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Wait for the command to complete */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(!(FTFE_FSTAT &amp;amp; FTFE_FSTAT_CCIF_MASK)){}; // this is the while loop where it resets&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Using the debugger and going line by line starting at the command setting the CCIF bit in the FSTAT I was able to set the flex memory the way I wanted.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Now if the debugger was not stepping line by line at the last while loop the program will Lockup again and the core resets.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Anyone has any thoughts about this issue ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Feb 2015 01:12:40 GMT</pubDate>
    <dc:creator>al1</dc:creator>
    <dc:date>2015-02-20T01:12:40Z</dc:date>
    <item>
      <title>K21 Flex Memory Setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-Flex-Memory-Setup/m-p/387753#M20928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;I reviewed couple of posts regarding setting flex memory on Kinetis devices and so far I am still facing issues with setting the Flex memory on the MK21FX512VLQ12.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;First I am using the PE to set peripherals, using the Cpu_SetFlexNVMPartition() causes the core to lockup and reset (lockup bit in RCM_SRS1 is set) so I gave up on using this function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;I tried the following code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (FTFE_FSTAT &amp;amp; FTFE_FSTAT_ACCERR_MASK)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FSTAT = FTFE_FSTAT_ACCERR_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Write the FCCOB registers */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB0 = FTFE_FCCOB0_CCOBn(0x80); // Selects the PGMPART command&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB1 = 0x00;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB2 = 0x00;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB3 = 0x00;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* FCCOB4 is written with the code for the subsystem sizes (eeprom_size define) */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB4 = 0x18; //64bytes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* FFCOB5 is written with the code for the Dflash size (dflash_size define) */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FCCOB5 = 0x0B; //32KB for data and 96KB for EE Backup&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* All required FCCOBx registers are written, so launch the command */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (!(FTFE_FSTAT &amp;amp; FTFE_FSTAT_CCIF_MASK)){};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTFE_FSTAT = FTFE_FSTAT_CCIF_MASK;&amp;nbsp; // step in line by line after this line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Wait for the command to complete */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(!(FTFE_FSTAT &amp;amp; FTFE_FSTAT_CCIF_MASK)){}; // this is the while loop where it resets&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Using the debugger and going line by line starting at the command setting the CCIF bit in the FSTAT I was able to set the flex memory the way I wanted.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Now if the debugger was not stepping line by line at the last while loop the program will Lockup again and the core resets.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Anyone has any thoughts about this issue ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Feb 2015 01:12:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-Flex-Memory-Setup/m-p/387753#M20928</guid>
      <dc:creator>al1</dc:creator>
      <dc:date>2015-02-20T01:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: K21 Flex Memory Setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-Flex-Memory-Setup/m-p/387754#M20929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello al1:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The part of code for launching the program partition and waiting for it to complete should be placed in RAM space. With the debugger it works because the core does not try to read the next instruction from flash right away, giving the command enough time to finish. Below is an extract from the reference manual:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/50713i4697A371DDB49763/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The syntax to locate code in RAM is compiler dependent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!,&lt;BR /&gt;Jorge Gonzalez&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Feb 2015 01:20:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-Flex-Memory-Setup/m-p/387754#M20929</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2015-02-24T01:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: K21 Flex Memory Setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-Flex-Memory-Setup/m-p/387755#M20930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jorge,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am revisiting this issue and at this moment I am looking for the best way to set up the Flex memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If during operation I understand the code section related to lunching the flash command need to be executed from RAM. What is the best way to do this knowing that I am using the latest KDS 3.0.0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to completely ignore setting up the flash from within the code and just do it while flashing the device on production line?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 20:48:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-Flex-Memory-Setup/m-p/387755#M20930</guid>
      <dc:creator>al1</dc:creator>
      <dc:date>2015-07-08T20:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: K21 Flex Memory Setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-Flex-Memory-Setup/m-p/387756#M20931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Replying to my second question in the previous reply, I found where the partition settings can be programmed initially inside KDS without the need to worry about configuring it while code is running.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;under the debugger tab the advanced tab will show this window:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/52903i6D76016FAD941DD7/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In red is where I set up the partition I want during the programming process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My first question still out, is there a simple example on how to relocate into RAM let's say the line &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; FTFE_FSTAT = FTFE_FSTAT_CCIF_MASK which will quick start the partitioning of the internal memory?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2015 22:54:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-Flex-Memory-Setup/m-p/387756#M20931</guid>
      <dc:creator>al1</dc:creator>
      <dc:date>2015-07-09T22:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: K21 Flex Memory Setup</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-Flex-Memory-Setup/m-p/387757#M20932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello al1:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may give a check to this document:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/docs/DOC-104433"&gt;Relocating Code and Data Using the KDS GCC Linker File for Kinetis&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may also check the &lt;A href="http://cache.freescale.com/files/32bit/software/C90TFS_FLASH_DRIVER.exe"&gt;&lt;STRONG&gt;C90TFS&lt;/STRONG&gt;&lt;/A&gt; flash driver package, which shows a different approach without modifying the linker file, by copying the code to a buffer stored in RAM and then executing from there. This driver also supports the partition command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Jorge Gonzalez&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2015 23:12:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K21-Flex-Memory-Setup/m-p/387757#M20932</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2015-07-09T23:12:50Z</dc:date>
    </item>
  </channel>
</rss>

