Question

I am working on embedded project with Keil MDK-ARM compiler. I try to access to external memory as heap but when I download my program in my micro (micro is a lpc1788) after the download is done it crashed (without start main function) in startup.c file, although I can access to external memory (before increase heap part).

Now can anyone provide a small sample project how to configure uVision, using the external RAM as heap? I want to configure uVision for program execution in internal FLASH using internal and external RAM for STACK and HEAP.

Was it helpful?

Solution

First specify the external ram range for RAM1 (for example) in the project Target settings dialog, and make sure all other settings are appropriate for your project.

Then in the Linker settings tab, un-check the "Use Memory Layout from Target Dialog" option. This will allow you to manually edit the scatter file which will initially reflect the layout defined in the Target settings.

Edit the scatter file to create a section in external ram thus (for example):

  RW_RAM1 0x60000000 UNINIT 0x00040000  {  ; RW data
    *(HEAP)  ; external SRAM
  }

The actual addresses may differ for your part. If you want to use all external RAM for heap that is sufficient, if you want to allow the linker to place other data in this space then:

  RW_RAM1 0x60000000 UNINIT 0x00040000  {  ; RW data
    *(HEAP)  ; external SRAM
    .ANY (+RW +ZI)
  }

Check the map file for the HEAP section to verify that the space was allocated as required.

You can similarly relocate the stack if necessary. But be aware that the external memory access may be be slower than internal so doing so may affect performance.

All this assumes of course that you have correctly initialised the external RAM controller to match the external RAM device - this should be done in system_lpc1788.c (or the similarly named file for your start-up code - my experience is with STM32 so I don't know, perhaps system_lpc17xx.c)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top