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.

CC2340R5: CC2340R5 Memory Consumption

Part Number: CC2340R5
Other Parts Discussed in Thread: SYSCONFIG, CC2640

Hi,

We are using the CC2340R5 part number its consumes 20KB for heap area in RAM. If we reduce the heap Memory it's advertise but, its not paring with any mobile. we configured in peripheral + observer role.

Same application is working the CC2640R2 without any issue. kindly explain what are the difference between memory of both part numbers. and how could I use the Peripheral + central  role in CC2340R5.

Thanks 

  • Hi,

    Thanks for reaching out! We will look into this and get back to you shortly. Could you share which project you are using as well as the SDK version you have installed?

    Best regards,

    Luke

  • Hi,

    I am using “SimpleLink Low Power F3 SDK (7.40.00.64)” 

    Thanks

  • Hi,

    Thank you for reaching out. The CC2340R5 is our next generation device and runs on the SimpleLink Low Power F3 SDK while the CC2640R2 device is a prior-generation device which runs on the SimpleLink CC2640R2 SDK. There are significant SDK and hardware differences between these devices.

    The CC2340R5 device is able to support multirole operation. Can you specify what behavior you are seeing when the device doesnt pair? Does the application hang or crash? Does the application continue running? Are you able to disconnect succesfully?

    Best Regards,

    Jan

  • Hi Jan,

    We are using SimpleLink Low Power F3 SDK (7.20) SDK and we use Data Stream example code is our base code. We have modified some configurations for the multi role (Pheripheral + Central) and UART. Also we enabled Timer. We configured heap size as #define configTOTAL_HEAP_SIZE ((size_t)(0x5000)). It will work as expected like Advertising, Connection, Pairing and Communicating as expected. We need to add more modules in our applications like ANCS and TPMS. After Adding these modules we face failure in the Memory allocation. 

    Then we have reduced the heap size #define configTOTAL_HEAP_SIZE ((size_t)(0x4000)). But the device does not Advertising. Is 20K heap is required for this application? or is there any other possible ways to optimize the memory?

    I have attached the both screenshots -  success when we are using only TI example & Failure when we are porting the our application with TI example. 

  • Hi, 

    we have using the CC2640r2, memory consumption are

    MEMORY CONFIGURATION

             name            origin    length      used     unused   attr    fill

    ----------------------  --------  ---------  --------  --------  ----  --------

      FLASH                   00000000   0001f000  00015c08  000093f8  R  X

      FLASH_LAST_PAGE 0001f000   00001000  00000058  00000fa8  R  X

      SRAM                    20000000   00004400  00002a05  000019fb  RW X

    same application we integrate in cc2340R5 but memory consumption are

    MEMORY CONFIGURATION

             name              origin      length            used          unused   attr    fill

    ----------------------  --------  ---------  --------  --------  ----  --------

      FLASH                   00000000   0007c000  0002fd85  0004c27b  R  X

      NVS_SLOT                0007c000   00004000  00004000  00000000  R  X

      SRAM                    20000000   00009000  00008248  00000db8  RW X

      CCFG                    4e020000   00000800  00000800  00000000  RW

    what is the differences between the both here 36kB is available. it is comparatively higher than cc2640r2. we are using 10kB RAM. but the RF core itself taking more memory in user space.  please expedite to the solution for next step. now we are stopped.

    Thanks,

  • Hi,

    Got it. I think the lack of RAM space may be resolved by reducing the heap. Can you try reducing the heap and verifying if the project is able to link?

    Best Regards,

    Jan

  • Hi, 

    I have mentioned in initially, if I reduce the heap memory it is compiled but not working in the sense ble not pairing uart callback not happening. So why rf core taking more memory space. Please I am in final stage of this project kindly expedite.

    Thanks,

  • Hi,

    Got it. My apologies for the confusion. To clarify, the connection is still taking place but the pairing is not occurring? Can you share the pairing settings used in sysconfig? Are any of the pairing functions being called? If so, then could you share the return codes? Do you have access to a bluetooth sniffer? If so, then could you take a sniffer log of the device advertising, connecting, and attempting to pair?

    Best Regards,

    Jan

  • Hi Jan

    I have shared the pairing settings and pairing functions for your reference. And advertising and connection log of mobile app and sniffer was shared. 

    nRF Connect, 2024-03-07
    12345678901000000000 (A4:34:F1:AE:D8:30)
    V	14:23:57.047	Connecting to A4:34:F1:AE:D8:30...
    D	14:23:57.047	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	14:23:58.422	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	14:23:58.422	Connected to A4:34:F1:AE:D8:30
    D	14:23:58.449	[Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_CONSENT (3)
    D	14:23:58.596	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D	14:23:58.598	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
    I	14:23:58.883	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    I	14:23:59.211	Connection parameters updated (interval: 30.0ms, latency: 0, timeout: 5000ms)
    D	14:24:02.258	[Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_PIN (0)
    D	14:24:07.922	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10)
    I	14:24:07.922	Bonding failed
    V	14:24:07.923	Discovering services...
    D	14:24:07.923	gatt.discoverServices()
    D	14:24:07.929	[Callback] Services discovered with status: 0
    I	14:24:07.929	Services discovered
    V	14:24:07.933	Generic Access (0x1800)
    - Device Name [R W] (0x2A00)
    - Appearance [R W] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    - Central Address Resolution [R] (0x2AA6)
    - Resolvable Private Address Only [R] (0x2AC9)
    Generic Attribute (0x1801)
    - Service Changed [I] (0x2A05)
       Client Characteristic Configuration (0x2902)
    Device Information (0x180A)
    - System ID [R] (0x2A23)
    - Model Number String [R] (0x2A24)
    - Serial Number String [R] (0x2A25)
    - Firmware Revision String [R] (0x2A26)
    - Hardware Revision String [R] (0x2A27)
    - Software Revision String [R] (0x2A28)
    - Manufacturer Name String [R] (0x2A29)
    - IEEE 11073-20601 Regulatory Certification Data List [R] (0x2A2A)
    - PnP ID [R] (0x2A50)
    Unknown Service (f000c0b1-0451-4000-b000-000000000000)
    - Unknown Characteristic [W] (f000c0c1-0451-4000-b000-000000000000)
       Characteristic User Description (0x2901)
    - Unknown Characteristic [N] (f000c0d1-0451-4000-b000-000000000000)
       Client Characteristic Configuration (0x2902)
       Characteristic User Description (0x2901)
    D	14:24:07.934	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
    D	14:24:07.935	gatt.setCharacteristicNotification(f000c0d1-0451-4000-b000-000000000000, true)
    I	14:24:10.561	PHY updated (TX: LE 2M, RX: LE 2M)
    D	14:24:10.926	[Callback] Connection state changed with status: 22 and new state: DISCONNECTED (0)
    E	14:24:10.926	Error 22 (0x16): GATT CONN TERMINATE LOCAL HOST
    I	14:24:10.926	Disconnected
    D	14:24:10.954	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    D	14:24:49.852	gatt.close()
    D	14:24:49.855	wait(200)
    V	14:24:50.057	Connecting to A4:34:F1:AE:D8:30...
    D	14:24:50.057	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	14:24:50.200	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	14:24:50.200	Connected to A4:34:F1:AE:D8:30
    D	14:24:50.236	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D	14:24:50.236	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
    D	14:24:50.240	[Broadcast] Action received: android.bluetooth.device.action.PAIRING_REQUEST, pairing variant: PAIRING_VARIANT_CONSENT (3)
    I	14:24:50.665	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    I	14:24:50.991	Connection parameters updated (interval: 30.0ms, latency: 0, timeout: 5000ms)
    I	14:25:11.073	PHY updated (TX: LE 2M, RX: LE 2M)
    D	14:25:22.923	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_NONE (10)
    I	14:25:22.923	Bonding failed
    V	14:25:22.930	Discovering services...
    D	14:25:22.930	gatt.discoverServices()
    D	14:25:22.934	[Callback] Services discovered with status: 0
    I	14:25:22.934	Services discovered
    V	14:25:22.941	Generic Access (0x1800)
    - Device Name [R W] (0x2A00)
    - Appearance [R W] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    - Central Address Resolution [R] (0x2AA6)
    - Resolvable Private Address Only [R] (0x2AC9)
    Generic Attribute (0x1801)
    - Service Changed [I] (0x2A05)
       Client Characteristic Configuration (0x2902)
    Device Information (0x180A)
    - System ID [R] (0x2A23)
    - Model Number String [R] (0x2A24)
    - Serial Number String [R] (0x2A25)
    - Firmware Revision String [R] (0x2A26)
    - Hardware Revision String [R] (0x2A27)
    - Software Revision String [R] (0x2A28)
    - Manufacturer Name String [R] (0x2A29)
    - IEEE 11073-20601 Regulatory Certification Data List [R] (0x2A2A)
    - PnP ID [R] (0x2A50)
    Unknown Service (f000c0b1-0451-4000-b000-000000000000)
    - Unknown Characteristic [W] (f000c0c1-0451-4000-b000-000000000000)
       Characteristic User Description (0x2901)
    - Unknown Characteristic [N] (f000c0d1-0451-4000-b000-000000000000)
       Client Characteristic Configuration (0x2902)
       Characteristic User Description (0x2901)
    D	14:25:22.941	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
    D	14:25:22.944	gatt.setCharacteristicNotification(f000c0d1-0451-4000-b000-000000000000, true)
    D	14:25:25.884	[Callback] Connection state changed with status: 22 and new state: DISCONNECTED (0)
    E	14:25:25.884	Error 22 (0x16): GATT CONN TERMINATE LOCAL HOST
    I	14:25:25.884	Disconnected
    D	14:25:25.918	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    
    Log1.psd

  • Hi,

    Given the reason "GATT CONN TERMINATE LOCAL HOST" it seems that the phone is the one disconnecting for some reason. Does this happen with other phones (different OS and/or models)? Also, does the application hang after this disconnect or are you able to re-connect without resetting?

    Best Regards,

    Jan

  • Hi,

    same is happening for all the models and phones.

    after reset only it will advertise.

    Thanks

  • Hi,

    Understood. It sounds like the device is hanging somewhere. If you pause execution, can you share where the program pauses?

    Best Regards,

    Jan

  • Hi

    I have paused the execution. It was stuck due to the iCall_abort()in the function GATT_WriteCharValue. I have attached picture for your reference.

  • Hi,

    Can you confirm the context in which the GATT function is being called? Are you within the ble task function? If not, then could you try using the BLEAppUtil_invokeFunctionNoData() to call the GATT_WriteCharValue() function? This will ensure the function is called within the proper context. The following E2E thread shows an example of how to use this function: https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1267648/cc2340r5-central-is-going-to-hang-when-invoke-function-is-given-to-the-gpio-callback

    Best Regards,

    Jan

  • Hi Jan,

    I have tried using the BLEAppUtil_invokeFunctionNoData() method but it never helped for me. The iCall_abort() is happening due to the function AMS_CCCDConfig(AMS_handleCache[AMS_REMOTE_CONTROL_HDL_CCCD], TRUE)  in the GATT_WriteCharValue(). It goes to icall abort() or it returns status 22 instead of SUCCESS. I have tested this in multiple test scenario.

    And also, I have analyzed 2 E2E threads but it's not resolved my issue.

    CC2340R5: CC2340 stuck in ICall_abort - Bluetooth forum - Bluetooth®︎ - TI E2E support forums

    https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1284206/cc2340r5-cc2340-ported-ancs-but-the-module-can-t-receive-cell-phone-data

    test scenario 1:

    I have taken reference with Simple peripheral example code (peripheral + observer role) and ported ams and ancs part. I have tested in this using CC2640 and CC2642 (multirole example code as base code) it works fine no error occurred.

    test scenario 2:

    I have taken reference with basic Ble code (Only using the peripheral role) and ported ams part the icall abort is happening like the way previously I said.

    The free heap size also I have verified before calling the GATT_WriteCharValue() function the heap size is available near 8KB. I have attached image for your reference. I have tested this using CC2340R5.

    test scenario 3:

    I have taken reference with data Stream example code with peripheral + central role. And enabled ANCS part in that code. in this function I have two functions one is Ancs_subsDataSrc() and other one is Ancs_subsNotifSrc() I have attached image for your reference. both functions are trying to write the request using GATT_WriteCharValue() function. I am getting icall abort using these functions at the same time. If I use any one of the subscription functions I won't get any error, it works fine as I expected.  I have tested this using CC2340R5.

    test scenario 4:

    I have taken reference with data Stream example code with peripheral. And enabled ANCS part in that code It works fine. I have tested this using CC2340R5.

    Kindly analyze these scenario's and clarify why I am getting error in the CC2340R5. I am in the final stage of this project kindly help me to resolve this issue.

  • Hi,

    Got it. Thank you for the additional information. The return code 22 (0x16) maps to blePending which occurs when the stack is still processing a previously queued up event and the queue is full. Can you try increasing the PDU size and amount to see if this has an impact on the behavior? This can be through in the bluetooth module in Sysconfig. Try setting these to the max value and seeing if a chance is obvserved.

    Best Regards,

    Jan

  • Hi Jan

    Already I configured the MAX_PDU_SIZE 255. But the issue is still there.

  • Hi,

    Thank you for confirming. I would like to see if the ble5-stack itself is running out of heap. The Debugging Common Heap Issues section of the user's guide shows how to measure the heap during runtime. Could you check what heap size is reported in ROV when following those steps? It would be helpful to know the heap in the lead up to the behavior occurring and after it occurs.

    Best Regards,

    Jan

  • Hi Jan 

    I have shared the heap information in the previous chat. Once again, I will share the heap size in ROV. Kindly check it out and we are in the urge to complete this. Is there any possible way to connect with you for this issue? Kindly help us to solve this as soon as possible.

    Thanks

    Brindha K

  • Hi,

    The heap looks correct to me.

    Could you please also take a look at the stack of each task? This can be done similarly to what you have done for the heap, selecting the "task" module (and ensuring you use the "detailed" view).

    Best regards,

  • Hi 

    I have attached the task stack ROV for your reference. Kindly check with that and share your feedback.

    Regards

    Brindha K

  • Hi,

    The stack sizes look correct.

    For sanity, could you please confirm the heap and stack usage numbers have been collected after the issue has occurred?

    I have also a few other elements I would like you to check for sanity:

    • In SysConfig > BLE > Profiles Configuration > Maximum number of prepare writes can you double the value set?
    • In SysConfig > BLE > General Configuration > Max Number of PDUs can you double the value set?
    • In SysConfig > BLE > General Configuration > Max Number of Connections can you set "1"?

    Appreciate your patience while we are trying to figure out the issue.

    Best regards,

  • Hi

    Thanks for your suggestion. we tried these settings, but it seems like no improvement for us. 

    We need to know about the minimum RAM size required for the SDK with basic Ble example. And we established all the features like multirole (Central + Peripheral), AMS and ANCS with our UART applications in CC2640R2. But in cc2340R5 we can't implement Basic Peripheral with AMS functionality. We have available with free SRAM size near 8K still the functionality can't to be achieved. It seems like CC2340R5 is not suitable for our application.

    This way we have compared and selected. But here its consuming more RAM. So, we considering CC2340 is not replacement of CC2640.

    Regards

    Brindha K

  • Hi Brindha,

    Is your project all running on a single tasks or do you have seperate tasks for each functinoality? Can you try increasing/decreasing the task stack size allocated for each task? For example, for the appMain task, the task stack size may be modified here:

    Best Regards,

    Jan

  • Hi Jan,

    This had done very beginning itself, Do you understand the problem?. concern here is RAM memory, what is the exact RAM memory required for TI's RF stack.

    Please share exact details.

    Thanks ,

  • Hi,

    My apologies, you are right I missed that I had previously asked you to change this. To make sure I am understanding the behavior that you are experiencing, I will summarize it below. Please let me know if I missed anything

    When the stack size and/or heap size, unexpected BLE behavior is observed.

    1. Pairing does not succeed 

    2. Stack hangs at specific GATT_WriteCharValue

    However, if the stack size and/or heap size is not decreased, then no issues are observed.

    Is this the case?

    Best Regards,

    Jan

  • Hi Jan

    Your right

    1. Pairing does not succeed 

    2. Stack hangs at specific GATT_WriteCharValue

    But if the stack size and/or heap size is not decreased, still issues are observed.

    I attached the Ancs_CCCDConfig function for your reference. This function is called from AMS + ANCS both. Please confirm the memory allocation and free is correct we are using in this function. Is there any other function instead Ancs_CCCDConfig please let us know.

    Regards

    Brindha K

  • Hi Brindha,

    At a glance, it looks okay to me with regards to memory allocation and freeing. Instead of using GATT_WriteCharValue, could you try using GATT_WriteNoRsp() instead? In some of our sample projects, we use that instead when modifying the CCCD. Something like this:

    Best Regards,

    Jan

  • Hi Jan

    I have tried the GATT_WriteNoRsp with the modifications in CCCD as you said. But the issue is not resolved still the ICall_abort happens.

    I attached Image for your reference.

    Regards

    Brindha K

  • Hi Brindha,

    Understood, lets try to dig into why the icall_abort may be happening. Can you provide me with the value of ErrorNo variable when the abort is reached?

    Best Regards,

    Jan

  • Hi Jan

    I can't get value of the ErrorNo. After reached the abort function I stuck in the while loop. the variable j remains always 1.

    Regards

    Brindha K

  • Hi Brindha,

    Okay, i think we need to ensure HALL Asserts are enabled. There is some information about this in the ICall Abort section of the debugging guide and the HAL Assert Handling section. Can you reference these sections to see if we are able to extract the ErrorNo that way?

    Best Regards,

    Jan

  • Hi Jan

    We are concluded that the CC2340R5 is not capable for our application. I have shared the implemented features and its results in the step-by-step process in the attached table. We need the entire feature in our application. However, we don’t hope CC2340R5 is not suitable for our entire feature development.

    Thanks for the support.

    Sl .No Implemented feature Step by step Result
    1 Data stream example(BLE Peripheral + UART) + Timer Working
    2 Data stream example(BLE Peripheral + UART)  + Timer + Our applications Working
    3 Data stream example(BLE Peripheral + UART)  + Timer + ANCS Working
    4 Data stream example(BLE Peripheral + UART)  + Timer + ANCS + Our Applications Working
    5 Data stream example(BLE Peripheral + UART)  + Timer + ANCS + Our Applications + Added Multi role(Central + Peripheral) Insufficient memory issue while building the project
    6 Data stream example(BLE Peripheral + UART)  + Timer + Minimized our Applications (freed SRAM memory) + Added Multi role(Central + Peripheral) Working
    7 Data stream example(BLE Peripheral + UART)  + Timer + Minimized our Applications (freed SRAM memory) + Added Multi role(Central + Peripheral) + ANCS ICall abort error
    8 Data stream example(BLE Peripheral + UART)  + Timer + Minimized our Applications (freed SRAM memory) + ANCS + AMS ICall abort error
    9 Data stream example(BLE Peripheral + UART)  + Timer + ANCS + AMS ICall abort error
    10 Data stream example(BLE Peripheral + UART)  + Timer + AMS ICall abort error
    11 Basic BLE example(BLE Peripheral) + Timer + ANCS + AMS ICall abort error
    12 Basic BLE example(BLE Peripheral + UART)  + Timer + AMS ICall abort error

    Regards

    Brindha K

  • Hi Brindha,

    Thank you for the table. I apologize that you have encountered these development issues during your evaluation. With regards to the ICall abort error, I believe these are likely due to an application code error somewhere. To resolve these, I would take the minimal project that exhibits this ICall abort and debug it. If you share the project here, I would be happy to take a closer look.

    Best Regards,

    Jan

  • Hi Jan,

    You just take the Basic BLE example and include only the AMS feature in that code. "Basic BLE example (BLE Peripheral + UART) + Timer + AMS" in this scenario we don't add our applications. Just testing with the Example code + AMS we got ICall_abort. Kindly debug like the above-mentioned way. If u don't face any ICall_abort error, please share the code it will be great help for us.

    Regards

    Brindha K

  • Hi Brindha,

    Got it. I do not have an AMS project on my side unfortunately. Are you able to share a minimized AMS project with the issue? I should be able to debug that and figure out what may be triggering the abort.

    Best Regards,

    Jan