NXP LPC1768 AHB SRAM banks

08 Mar 2010


According to LPC17xx user manual the LPC1768 has a total of 64kB of SRAM. I understand that there is a 32kB bank of SRAM connected to the CPU's instruction and data busses, which is readily accessible.

There are two more 16kB banks of SRAM which are stated as typically being used for peripheral data but can supposedly still be used for general purpose instruction and data storage.

However, from what I've searched through on the forums it seems like one can only access 32kB of SRAM. Is it possible to access the other 16kB banks?



09 Mar 2010

Here's the linker control file used by online IDE (from SVN):


LR_IROM1 0x00000000 0x80000  {    ; load region size_region
  ER_IROM1 0x00000000 0x80000  {  ; load address = execution address
   *.o (RESET, +First)
   .ANY (+RO)
  RW_IRAM1 0x10000000 0x8000  {  ; RW data, Application data
   .ANY (+RW +ZI)
  RW_IRAM2 0x2007C000 0x4000  {  ; RW data, USB RAM
  RW_IRAM3 0x20080000 0x4000  {  ; RW data, ETH RAM
  RW_IRAM4 0x40038000 0x0800  {  ; RW data, CAN RAM


As you can see, it places any code or RO data not marked specifically into the 0x00000-0x80000 range, and the RW stuff into IRAM1 (0x10000000-0x10008000). To place things into other ranges, you'll need to declare it as belonging to those sections (AHBSRAM0/1 or CANRAM). To do that, you can use __attribute__((section("name"))) (for variable declarations) or #pragma arm section. I don't know if actual code will execute from there, but I suspect at least the AHBSRAMx will.

See Using Scatter-loading Description Files for more details. The Linker User Guide is also available in PDF.

24 Jul 2010

Hi Igor,

I also need to use the extra RAM space, I have tried your method. However, an error occurred.

what I write in main is :  float f1[2048] _attribute_ ((section("AHBSRAM0")));

error: The "section" attribute does not apply to local variables...

Would you inform me what is wrong?

Thank you

24 Jul 2010

Never mind,I needed to instantiate them globally.



03 Apr 2013

Just tried this and it's not working... Is there a file that I should be including?

float f1[2048] _attribute_ ((section("AHBSRAM0")));

"expected a ";"" in file "/main.cpp", Line: 51, Col: 17

04 Apr 2013

Sorry, should have been with two underscores:

float f1[2048] __attribute__ ((section("AHBSRAM0")));


18 Dec 2013

So would something like the following work to place a class or method in AHBSRAM0?

int someclass::somemethod( void ) attribute ((section("AHBSRAM0"))) { return(1); }