RAM

There is 28 kB of RAM available in the CC2340R2 and 36 kB in the CC2340R5. The various sections of RAM and their associated linker files are as follows.

  • CSTACK: This the system callstack used by the C main function and HWIs.

  • RAM Reset Vector Table: This table holds entries for all supported reset vectors. It is initialized from the flash reset vector table at boot time and is used to plug interrupt table entries at runtime.

For projects where the stack project builds a library:

  • Application and Stack statically allocated data: This includes any initialized and uninitialized variables used by the application or stack. (.data,.bss)

RAM Usage

Like most of the embedded processors, the RAM of the CC23xx is used to store dynamic data (such as the global variables, the threads’ stacks, and the system’s heap). Developers can split the usage of the available RAM according to their needs.

When building the program, the linker will raise an error if the RAM size required by the user exceeds the RAM size specified in the linker command file. In the linker command file, the device’s RAM size is defined by the symbol RAM_SIZE. Executing a project built with the RAM_SIZE value set to a larger value than the RAM actually available on the device may lead to unexpected behaviors.

Note

For the CC23xx, the linker is NOT configured to auto-size the heap as it is the case on other SimpleLink devices. Optimal RAM usage is achieved by allocating all the unused RAM as heap.

Heap and Stack sizing

The following steps show how to maximize the heap memory (in order to use all the RAM available on the device and have an optimal RAM usage):

  • Build the project and go to .map file

  • Check Unused SRAM section at the top of the .map file

    ../_images/check_ram_usage_map_file.png
  • In the FREERTOS section of the .syscfg file, go to the Stack and Heap sizing section.

  • Increase the Heap size value based on the amount of SRAM left unused previously. Due to memory alignment constraint you will likely not be able to allocate all the available RAM.

    ../_images/change_heap_size_freertos_sysconfig.png

The ROV can be leveraged when running the program with the debugger attached to observe the heap used after device boots, this will indicate the real amount of memory the application has left to run. (Further instruction can be found in the ROV section in Debugging)

See Check System Flash and RAM Usage With Map File for the procedure to check the size of the configured protocol stack.

Warning

The out-of-the-box projects are configured to leave only a few bytes of RAM non-allocated. This can be misleading when looking at the available RAM in the out-of-the-box projects.

On the unmodified projects, the heap size can be reduced without altering the functioning of the project.