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?
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?
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:
RAM configuration for S110 softdevice, 16kB RAM (e.g. nRF51 QFAA variant) could be:
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:
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.
Hi. We did not make time yet to dig into how to do this for GCC. Hopefully, someone can share info on that.
Hi. We did not make time yet to dig into how to do this for GCC. Hopefully, someone can share info on that.
Good1 Is it possible to add instructions for us who don't have KEIL, but use SES now? Thanks!
That would be much appreciated!