This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to execute code from RAM on nRF51

According to nRF51822/nRF51422 PS v3.1 table 34, current consumption can be decreased by executing code from RAM instead of from flash. How is it possible to execute code from RAM?

Parents
  • First you must define a specfic RAM block, then you need to assign your code to that RAM block.

    RAM block layout is described in nRF51822/nRF51422 PS v3.1, table 6 and table 7. So the way to do this is to devide the RAM into two sections in Keil -> Options for Target and then assign the spi_slave.c RAM to the IRAM2 section as shown in the following images.

    RAM configuration for S110 softdevice, 32kB RAM (e.g. nRF51 QFAC variant) could be:

    image description

    RAM configuration for S110 softdevice, 16kB RAM (e.g. nRF51 QFAA variant) could be:

    image description

    Right click the source code file in Keil and select "Options for File 'main.c' if you want to place source code for main.c into RAM:

    image description

    Note that different softdevices reserve RAM space on the chip so there is limited amount of RAM remaining for the application, especially for 16kB RAM variants. The above configuration may be different for other softdevices as they use different amount of RAM, see Softdevice Specification (SDS) for the relevant softdevice, chapter about resource usage. Compatibility of different SDS's and softdevices is listed in the nRF51 compatibility matrix.

    Also note that 2kB is reserved from the application RAM space for the softdevice and application stacks, see this thread and this thread

    Make sure to allocate enough RAM space for the source code that you assign to RAM. It can be seen in the .map file in the _build folder how much RAM is actually used by the source file that are assigned to RAM.

  • Nice tutorial! I really appreciate you.

    I have a question. I'm using IAR for ARM (in Windows 7) and GCC (in Fedora 13) when I work with my board.

    Then what settings should be needed when I want to run my codes in the RAM?

    I'm using Softdevice S110 7.1 and SDK 7.2 .

Reply Children
No Data
Related