Any way to access the other 32KB?

26 Apr 2011

The NXP LPC1768 processor has 64KB of RAM, but apparently 32KB is dedicated RAM for some peripherals (Ethernet, USB and CAN). I’m not using any of those so I was wondering if there is any way to reallocate some of that for standard memory?

I really need about 55KB of RAM to maintain the data access speeds for my application. Thanks for any help?

27 Apr 2011

You can see the memory layout in LPC1768.sct. To use the extra regions, you can place your arrays using the section names:

static char buf1[0x2000] __attribute__((section("AHBSRAM0")));

But why do you need 55KB? There might be better ways to solve your issues.

27 Apr 2011

Thank you for your response; I’ll do some testing to see if I can split my data into those regions.

I’m opening and processing small BMP image files (96x96-24Bit), but I need to apply some transformations as quickly as possible. If I open and process the file directly from flash (or micro SD card) it takes about 320mS, however if I load the same file into and process from RAM, it only takes about 1.9mS. I’m trying to stay under 4mS. I’m confident I could figure some other ways to around the issue, but the easiest is just storing all of the data in RAM.

27 Apr 2011

The other way is, so long as you know nothing else is using AHBSRAM0 or AHBSRAM1 you can declare a pointer thus:-

    char *buf = (char *)(0x2007C000);

because the two RAM banks are next to each other in the memory map you now have a 32k buffer thus:

buf[0] to buf[0x7FFF]

You can of course use pointers like this to "chunk it up" however you like. Also, using this method means the build stats (shown on the right of the compiler screen after a build) don't show this memory as being used. But of course, it is in your case.

28 Apr 2011

I added some code to split my array between the main memory and this expanded area (0x2007C000). It seems to be working well!

Thanks for your help.

16 Feb 2012

Hi,

I know this is a bit of an older post but I also want more memory!

I wrote this test code...

#include "mbed.h"

Serial pc(USBTX,USBRX);

#define SIZE 19200

int main() {
    pc.printf("\n\r Extra memory test started...");

    char memory [SIZE];
    char *more_memory = (char *)(0x2007C000);

    for (int i=0; i<SIZE; i++) {
        memory[i] = 0x55;
        more_memory[i] = 0xAA;
    }

    pc.printf("\n\r Data written, reading back...");

    for (int i=0; i<SIZE; i++) {
        pc.printf(" %X, %X,",memory[i],more_memory[i]);
    }

    pc.printf("\n\r Test ended...");
}

Which seems to work well. But I am a bit worried about Andy's comment...

Andy K wrote:

The other way is, so long as you know nothing else is using AHBSRAM0 or AHBSRAM1 you can declare a pointer thus:-

I had a look through the datasheet and can't find AHBSRAM0 or AHBSRAM1. What are they? Also does the code above look OK? Is getting an extra 32kb of RAM this easy?

Regards Martin

16 Feb 2012

You can take a look at this post I made earlier this week in another thread. It shows how to see how much memory has been used in each bank and how to ask the compiler/linker to place variables into these other banks.

Hope that helps,

Adam

17 May 2013

I've been trying to use the ram in AHBSRAM0 or AHBSRAM1 but doing so causes crashes. I am using Ethernet, but not USB or CAN, so theoretically one of those banks should be free, however when I use either one, the thread crashes.

The code posted by Adam Green (thanks btw) yields the following results: Main RAM = 14536 RAM0 = 16384 RAM1 = 11220

Can anyone tell me why both SRAM banks appear to be used?

regards, Adrian.

28 May 2013

bump :)