This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: Minimum heap size for BLE peripheral role while using BLE4.2stack of CC2640R2_SDK_v1.35

Part Number: CC2640R2F
Other Parts Discussed in Thread: BLE-STACK, CC2640

Hi,

I'm using the CC2640R2F and BLE4.2 stack of CC2640R2_SDK_v1.35 to perform BLE peripheral role for my project. i have modified the simple_peripheral example for developing the project. The project has on-chip OAD functionality and customized algorithms(which are not using dynamic memory allocations) to carry out.  I have kept the value of HEAPMGR_SIZE=0 to allocate whatever memory unused for the heap.

But still, could you please let me know what should be the optimum heap size to be kept so that the peripheral role can be performed without any hiccups? i wanted to know how much my .bss and .data sections can grow without effecting the BLE operations.

Thank you.

  • Hi Vyshakh,

    In general, the minimum heap required is highly dependent on a number of things - and we encourage you do your own benchmarking determine the HEAP size required. The main dependencies are the which stack version you are using, how the stack is configured/which features are enabled, which compiler you are using, and the application's usage of dynamic memory.

    Again I highly recommend you benchmark this on your side as well with your set up (and post the numbers, I'm sure people will find it useful). Here's a brief list of steps to benchmark:

    Start with a base project from the stack/SDK you want to use; I'll be using BLE-Stack (4.2) with simple_peripheal, default stack configuration out of the box configuration from simplelink_cc2640r2_sdk_1_35_00_33. I'll be using IAR 7.80.3 as the IDE/Compiler, and the Stack_Library configuration.

    Enable HEAP Metrics, software-dl.ti.com/.../gen-debugging.html

    See the 'high water' mark in the HEAPMGR metrics: heapmgrBlkMax.
    Note; this doesn't account for various other elements important for characterizing HEAP usage, such as fragmentation. For a more rigorous test, you could create a statically allocated array and keep growing the array until the example is no longer functional. In this case, functionality means advertising, being connectable, and GATT table access - and there should be no heapmgrMemFails.

    Using a mix of the first and second methods listed above (getting an initial high water mark, and then setting a statically allocated array to that size) I found that the minimum HEAPMGR_SIZE with my set up is around 2000 bytes.

    I want to reiterate, definitely do this with your application and get the value for your application. Simple_peripheral does do some dynamic allocation, but it's not much. Majority of the allocations will be done in the TI BLE-Stack

    Also if Sensor Controller or the Cache isn't used, they can be utilized as General Purpose Ram: http://software-dl.ti.com/simplelink/esd/simplelink_cc2640r2_sdk/1.40.00.45/exports/docs/blestack/ble_user_guide/html/cc2640/memory_management.html


    I hope this helps,
    Rebel