<?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 Placing data into different RAM blocks in LPCXpresso IDE FAQs</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Placing-data-into-different-RAM-blocks/m-p/473455#M101</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many MCUs provide more than one bank of RAM. By default the managed linker script mechanism will place all of the application data and bss (as well as the heap and stack) into the first bank of RAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However it is also possible to place specific data or bss items into any of the defined banks for the target MCU, as displayed in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="font-family: monospace, courier; font-size: 1.1em; color: #646464; padding: 0.5em; background-color: #f0ece6;"&gt;&lt;SPAN style="font-size: 12pt; font-family: courier new,courier;"&gt;&lt;STRONG&gt;Project Properties -&amp;gt;&amp;nbsp; C/C++ Build -&amp;gt; MCU settings&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This placement is controlled via macros provided in an LPCXpresso header file which can be pulled into your project using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="font-family: monospace, courier; font-size: 1.1em; color: #646464; padding: 0.5em; background-color: #f0ece6;"&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 12pt;"&gt;&lt;STRONG&gt;#include &amp;lt;cr_section_macros.h&amp;gt;&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For simplicity, the *additional* memory regions are named sequentially, starting from 2, so RAM2, RAM3 etc (as well as using their "formal" region name - for example RamAHB32).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, the LPC1768 has a second bank of RAM at address 0x2007c000. The linker creates a new data (and&lt;/P&gt;&lt;P&gt;equivalent bss) load section:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="font-family: monospace, courier; font-size: 1.1em; color: #646464; padding: 0.5em; background-color: #f0ece6;"&gt;&lt;SPAN style="font-size: 12pt; font-family: courier new,courier;"&gt;&lt;STRONG&gt;.data_RAM2 : ALIGN(4) 
{ 
&amp;nbsp;&amp;nbsp;&amp;nbsp; FILL(0xff)
&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.data.$RAM2*)
&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.data.$RamAHB32*) 
} &amp;gt; RamAHB32 AT&amp;gt;MFlash512&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To place data into this section, you can use the &lt;STRONG&gt;__DATA&lt;/STRONG&gt; macro, thus:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: monospace, courier; font-size: 1.1em; color: #646464; padding: 0.5em; background-color: #f0ece6;"&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 12pt;"&gt;&lt;STRONG&gt;__DATA(RAM2) char data_buffer[1024] ; // create an initialised 1k buffer in RAM2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #646464; font-family: Arial, sans-serif; font-size: 12px;"&gt;&lt;/P&gt;&lt;P&gt;Or the &lt;STRONG&gt;__BSS&lt;/STRONG&gt; macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="font-family: monospace, courier; font-size: 1.1em; color: #646464; padding: 0.5em; background-color: #f0ece6;"&gt;&lt;SPAN style="font-size: 12pt; font-family: courier new,courier;"&gt;&lt;STRONG&gt;__BSS(RAM2) char bss_buffer[128] ; // create a zero-init buffer in RAM2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, if you do not place any data into these additional areas, then the linker does not create anything in those areas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to initialize additional RAM banks, the managed linker script mechanism will create a "Global Section Table" in your image, directly after the vector table. This contains the addresses and lengths of each of the data and bss sections, so that the startup code can then initialize them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The LPCXpresso generated startup code will then initialization of multiple regions by entering a loop reading this global section table, and calling a subroutine to carry out the initialization of each region it finds in the Global Section Table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H1 id="toc-hId-1904910981"&gt;Related FAQ&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389102" data-objecttype="1" href="https://community.nxp.com/thread/389102" rel="nofollow noopener noreferrer" target="_blank"&gt;Placing code/rodata into different FLASH blocks&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389101" data-objecttype="1" href="https://community.nxp.com/thread/389101" rel="nofollow noopener noreferrer" target="_blank"&gt;Placing data at an address&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389108" data-objecttype="1" href="https://community.nxp.com/thread/389108" rel="nofollow noopener noreferrer" target="_blank"&gt;Reserving RAM for ROM drivers&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Mar 2016 22:30:57 GMT</pubDate>
    <dc:creator>lpcware-support</dc:creator>
    <dc:date>2016-03-31T22:30:57Z</dc:date>
    <item>
      <title>Placing data into different RAM blocks</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Placing-data-into-different-RAM-blocks/m-p/473455#M101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many MCUs provide more than one bank of RAM. By default the managed linker script mechanism will place all of the application data and bss (as well as the heap and stack) into the first bank of RAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However it is also possible to place specific data or bss items into any of the defined banks for the target MCU, as displayed in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="font-family: monospace, courier; font-size: 1.1em; color: #646464; padding: 0.5em; background-color: #f0ece6;"&gt;&lt;SPAN style="font-size: 12pt; font-family: courier new,courier;"&gt;&lt;STRONG&gt;Project Properties -&amp;gt;&amp;nbsp; C/C++ Build -&amp;gt; MCU settings&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This placement is controlled via macros provided in an LPCXpresso header file which can be pulled into your project using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="font-family: monospace, courier; font-size: 1.1em; color: #646464; padding: 0.5em; background-color: #f0ece6;"&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 12pt;"&gt;&lt;STRONG&gt;#include &amp;lt;cr_section_macros.h&amp;gt;&lt;/STRONG&gt; &lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For simplicity, the *additional* memory regions are named sequentially, starting from 2, so RAM2, RAM3 etc (as well as using their "formal" region name - for example RamAHB32).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, the LPC1768 has a second bank of RAM at address 0x2007c000. The linker creates a new data (and&lt;/P&gt;&lt;P&gt;equivalent bss) load section:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="font-family: monospace, courier; font-size: 1.1em; color: #646464; padding: 0.5em; background-color: #f0ece6;"&gt;&lt;SPAN style="font-size: 12pt; font-family: courier new,courier;"&gt;&lt;STRONG&gt;.data_RAM2 : ALIGN(4) 
{ 
&amp;nbsp;&amp;nbsp;&amp;nbsp; FILL(0xff)
&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.data.$RAM2*)
&amp;nbsp;&amp;nbsp;&amp;nbsp; *(.data.$RamAHB32*) 
} &amp;gt; RamAHB32 AT&amp;gt;MFlash512&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To place data into this section, you can use the &lt;STRONG&gt;__DATA&lt;/STRONG&gt; macro, thus:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: monospace, courier; font-size: 1.1em; color: #646464; padding: 0.5em; background-color: #f0ece6;"&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 12pt;"&gt;&lt;STRONG&gt;__DATA(RAM2) char data_buffer[1024] ; // create an initialised 1k buffer in RAM2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #646464; font-family: Arial, sans-serif; font-size: 12px;"&gt;&lt;/P&gt;&lt;P&gt;Or the &lt;STRONG&gt;__BSS&lt;/STRONG&gt; macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="font-family: monospace, courier; font-size: 1.1em; color: #646464; padding: 0.5em; background-color: #f0ece6;"&gt;&lt;SPAN style="font-size: 12pt; font-family: courier new,courier;"&gt;&lt;STRONG&gt;__BSS(RAM2) char bss_buffer[128] ; // create a zero-init buffer in RAM2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, if you do not place any data into these additional areas, then the linker does not create anything in those areas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to initialize additional RAM banks, the managed linker script mechanism will create a "Global Section Table" in your image, directly after the vector table. This contains the addresses and lengths of each of the data and bss sections, so that the startup code can then initialize them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The LPCXpresso generated startup code will then initialization of multiple regions by entering a loop reading this global section table, and calling a subroutine to carry out the initialization of each region it finds in the Global Section Table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H1 id="toc-hId-1904910981"&gt;Related FAQ&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389102" data-objecttype="1" href="https://community.nxp.com/thread/389102" rel="nofollow noopener noreferrer" target="_blank"&gt;Placing code/rodata into different FLASH blocks&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389101" data-objecttype="1" href="https://community.nxp.com/thread/389101" rel="nofollow noopener noreferrer" target="_blank"&gt;Placing data at an address&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389108" data-objecttype="1" href="https://community.nxp.com/thread/389108" rel="nofollow noopener noreferrer" target="_blank"&gt;Reserving RAM for ROM drivers&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2016 22:30:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Placing-data-into-different-RAM-blocks/m-p/473455#M101</guid>
      <dc:creator>lpcware-support</dc:creator>
      <dc:date>2016-03-31T22:30:57Z</dc:date>
    </item>
  </channel>
</rss>

