<?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 RAM and Flash actually work? in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-RAM-and-Flash-actually-work/m-p/606405#M23622</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In C "static" defines the scope of a variable - it says&amp;nbsp;nothing about where it is stored. When applied to a variable defined in a module, the variable is only visible within that module. Look up "C storage classes" for more information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Flash is like ROM - you cannot write to it. So you cannot place a buffer in flash and expect it to work. Flash is for storing stuff that doesn't (or very rarely) changes. Flash can be *programmed* in blocks (sectors, or pages) by using a special algorithm, depending on whose flash is used - in NXP this is achieved by using the IAP calls as described in the User Manual. &amp;nbsp;For more info, see&amp;nbsp;&lt;A class="link-titled" href="https://en.wikipedia.org/wiki/Flash_memory" title="https://en.wikipedia.org/wiki/Flash_memory"&gt;Flash memory - Wikipedia&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Mar 2017 15:53:20 GMT</pubDate>
    <dc:creator>converse</dc:creator>
    <dc:date>2017-03-22T15:53:20Z</dc:date>
    <item>
      <title>How RAM and Flash actually work?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-RAM-and-Flash-actually-work/m-p/606402#M23619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to understand the procedure memory handling in LPC mcus.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working with an LPCxpresso 4367.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wanted to store a buffer in flash I tested this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;#include "board.h"&lt;P&gt;&lt;/P&gt;#define FLASHA_BASE_ADDR 0x1A000000&lt;BR /&gt;static int *fb&amp;nbsp; = (int *)FLASHA_BASE_ADDR;&lt;P&gt;&lt;/P&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SystemCoreClockUpdate();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Board_Init();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int arsize = 10;&lt;P&gt;&lt;/P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for (int i = 0; i &amp;lt; arsize; i++)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fb[i] = 0xA;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;P&gt;&lt;/P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;while (1) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;__WFI();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;}&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And after adding -print-memory-usage linker option i get this result:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;MFlashA512:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7984 B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 512 KB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.52%&lt;BR /&gt;RamLoc32:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 352 B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 32 KB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 1.07%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I went through normally without declaring specific address to fb buffer and i tested this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;#include "board.h"&lt;BR /&gt;&lt;BR /&gt;#define FLASHA_BASE_ADDR 0x1A000000&lt;BR /&gt;&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SystemCoreClockUpdate();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Board_Init();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int arsize = 10;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int fb[arsize];&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for (int i = 0; i &amp;lt; arsize; i++)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fb[i] = 0xA;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;while (1) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;__WFI();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;MFlashA512:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8044 B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 512 KB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.53%&lt;BR /&gt;RamLoc32:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 348 B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 32 KB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.06%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can some explain what is going on?&lt;/P&gt;&lt;P&gt;When i put fb in flash, flash occupied space is less.&lt;/P&gt;&lt;P&gt;When i put fb in ram, ram occupied space is less.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Mar 2017 11:09:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-RAM-and-Flash-actually-work/m-p/606402#M23619</guid>
      <dc:creator>dimitrissideris</dc:creator>
      <dc:date>2017-03-22T11:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: How RAM and Flash actually work?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-RAM-and-Flash-actually-work/m-p/606403#M23620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your &amp;nbsp;2nd example place fb on the stack, so it is 'allocated ' at run time .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in fact your 1st example doesn't place fb&amp;nbsp;in flash either... suggest you look up the meaning of static in C&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Mar 2017 12:31:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-RAM-and-Flash-actually-work/m-p/606403#M23620</guid>
      <dc:creator>converse</dc:creator>
      <dc:date>2017-03-22T12:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: How RAM and Flash actually work?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-RAM-and-Flash-actually-work/m-p/606404#M23621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did run again the examples without static. Same results&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;example1:&lt;/P&gt;&lt;P&gt;MFlashA512:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7984 B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 512 KB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.52%&lt;BR /&gt;RamLoc32:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 352 B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 32 KB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.07%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;example2:&lt;/P&gt;&lt;P&gt;MFlashA512:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8044 B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 512 KB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.53%&lt;BR /&gt;RamLoc32:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 348 B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 32 KB&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.06%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as example2 is concerned, ok it is allocated on run time. But why flashA has more space occupied?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example1 the question is if i can store this way a variable or a buffer in Flash memory&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Mar 2017 12:45:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-RAM-and-Flash-actually-work/m-p/606404#M23621</guid>
      <dc:creator>dimitrissideris</dc:creator>
      <dc:date>2017-03-22T12:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: How RAM and Flash actually work?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-RAM-and-Flash-actually-work/m-p/606405#M23622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In C "static" defines the scope of a variable - it says&amp;nbsp;nothing about where it is stored. When applied to a variable defined in a module, the variable is only visible within that module. Look up "C storage classes" for more information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Flash is like ROM - you cannot write to it. So you cannot place a buffer in flash and expect it to work. Flash is for storing stuff that doesn't (or very rarely) changes. Flash can be *programmed* in blocks (sectors, or pages) by using a special algorithm, depending on whose flash is used - in NXP this is achieved by using the IAP calls as described in the User Manual. &amp;nbsp;For more info, see&amp;nbsp;&lt;A class="link-titled" href="https://en.wikipedia.org/wiki/Flash_memory" title="https://en.wikipedia.org/wiki/Flash_memory"&gt;Flash memory - Wikipedia&lt;/A&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Mar 2017 15:53:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-RAM-and-Flash-actually-work/m-p/606405#M23622</guid>
      <dc:creator>converse</dc:creator>
      <dc:date>2017-03-22T15:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: How RAM and Flash actually work?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-RAM-and-Flash-actually-work/m-p/606406#M23623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dimitris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In addition to Con Verse information, I think that the following post could also help you understand how data is stored in Flash and RAM:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://mcuoneclipse.com/2013/04/14/text-data-and-bss-code-and-data-size-explained/" title="https://mcuoneclipse.com/2013/04/14/text-data-and-bss-code-and-data-size-explained/"&gt;text, data and bss: Code and Data Size Explained | MCU on Eclipse&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Hope it helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Carlos Mendoza&lt;BR /&gt;Technical Support Engineer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Mar 2017 22:06:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-RAM-and-Flash-actually-work/m-p/606406#M23623</guid>
      <dc:creator>Carlos_Mendoza</dc:creator>
      <dc:date>2017-03-23T22:06:51Z</dc:date>
    </item>
  </channel>
</rss>

