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.

CC2640: I can not discover the services/characteristics of my CC2640 when adding PWM driver (using multiple different hosts).

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

Hello, I have asked this related question some time ago.

I was facing the problem of being able to connect and discover characteristics only with certain types of hosts (such as Iphone 8, cc2640 host_test and might gecko). But, when I try to connect with another host (such as Iphone X, or BlueGecko) I cant pass the stage of discovering the characteristics after connecting.

Related or not, this happens when I add a PWM functionality (using ti/drivers/PWM.h).

I assume this is a problem with the TI-BLE Stack, since it was stated by  in my previous post

Is there a relation with the ti-blestack and ti-drivers or any memory flaw/leakage or inconsistency (such as the ID 0x80 from NVM being used by storing the Service Change Indication Flag) that prevents the peripheral from having its services/characteristics discovered?

How should I avoid this bug?

  • I was facing the same issue on a project some time ago. It seems to be a bug on TI PWM drivers or something like that. Also it may be related with PWM_init() since my application does not discover the characteristics when I enable it.
  • Hi Leoni,

    I don't understand your problem, can you be more clear? Are you able to discover characteristics from any master device when the PWM functionality is not added to your project?

    Can you post a sniffer log of the failed service/characteristic discovery? Without this, there is no way of knowing whether the CC2640 device or the master device is at fault.

    Are you using pairing or bonding?
  • Hello.

    * Sniffer logs are in my previous post: here. but for the sake of clarity, I' sniffed again with and without the PWM (possibly not related, but triggering the bug).

    * I'm not using either pairing or bonding. Just connection.

    * The problem is the one I have stated: Depending on the host, the PWM prevents the connection from being made (it disconnects when discovering characteristics).

    Sniffer:

    A good connection: 

    good_connection_log: good_connection.psd

    Bad connection:

  • Hi Leoni,

    Does the CC2640R2F hang?

    Normally you would see the master device continue to send connection event packets even if the slave stops responding (until the supervision timeout runs out).

    Your "good connection" log also seems to depict a non-success situation, since the slave doesn't return any ATT responses. (Or maybe the sniffer is just missing these packets?)

    What version of the BLE-Stack and SDk are you using? What example project did you base this on?
  • Hello Marie, 

    The cc2640r2f does not hang. I can still interact with its gpios.

    I'm using the simplelink 1.40.00.45. My project structure is based on the simple_peripheral (custom services generated using the TI plugin for the Bluetooth Developer Studio and I'm using the project_zero.c as main bluetooth application task.)

    My application uses only one application task (just the task from the project_zero.c modified).

    Regards.

  • Hello Marrie,

    Do you have any example with PWM/Buzzer and Ble Stack working to reference here? I am also interested on that.

    Thank you.
  • Hi Leoni,

    I cannot see that the PWM driver itself would block the BLE-Stack from sending packets, unless you are using critical sections in your application.

    Can you confirm that the application always works when connecting to any master device when you are not using PWM?

    Can you check your task stack size when this happens?

    I think it may be possible that you have run into this known issue (See blestack release notes):
    "Link Layer Connection Parameters Request Procedure is disabled on most peripheral applications to improve connection parameter request compatibility with smart phone devices. L2CAP LE Signaling will be used instead. Define USE_LL_CONN_PARAM_UPDATE in application project to override this behavior"

    This issue was fixed in the latest release (CC2640R2 2.30 SDK). Can you update to this SDK version and retry?
  • Hi Leandro,

    No we don't have any example projects with both BLE and PWM.
  • Hello Marie

    Can you confirm that the application always works when connecting to any master device when you are not using PWM?

    Yes it works. as soon as I call PWM_init(); it stops working.

    Can you check your task stack size when this happens? 

    this is the stack size of the main task

    #define PRZ_TASK_STACK_SIZE                   800

    I also tried to define USE_LL_CONN_PARAM_UPDATE but nothing changed.

    Regards.

  • Hi Leoni,

    Can you check how much of your task stack is free/whether you have a stack overflow when this happens? You can see this in the task view of the ROV.

    You are already using USE_LL_CONN_PARAM_UPDATE from you master side according to the sniffer log. The fix for LL Connection parameter update was added in the latest SDK (CC2640R2 2.30 SDK). Can you update to this SDK version and retry?
  • Hello Marie, 

    Here is my stack peak in each existent task:

      

    I'm currently trying with the new stack. I'll keep you informed.

    Regards.

  • Hi Leoni,

    Did the stack update solve your problem? I will close this thread due to inactivity.
  • Please do not close the thread yet for I'm not done with the porting.

    A lot changed from the sdk 1.40.00.and I had to modify the structure of the firmware.

    But could you infer anything with the stack size I sent in the previous post?

  • Hello Marie,
    As soon as I port the code to the new sdk, I face an issue of memory placement:

    Program will not fit into available memory. placement with alignment fails for section ".cinit" size 0xfaf . Available memory ranges: cc26xx_app.cmd - /ble5_project_zero_cc2640r2lp_app/TOOLS 

    As soon as I disable the logs, I can build and link the program.

  • Hi Leoni,

    Your stack sizes look all right, how long did you run the program before taking the screen shot?

    Your memory placement issue is simply that your code is too big. You can find some advice for slimming it down here: dev.ti.com/.../creating-a-custom-bluetooth-low-energy-application.html

    Removing any code your not using is of course the first step.
  • Hello Marie.

    I ran for just about 5 seconds (tried to connect, failed, took screenshot).

    I'll take a look at those memory placement by tomorrow issues and I'll keep you informed.

  • Hi Leoni,

    Did you manage to fit your code? Do you still have an issue?

    I will close this thread due to inactivity,
  • I'm not working on this right now,

    but can I re-open the thread as soon as I come back again to this matter?

    Otherwise, I would like to keep the thread open.

  • Hi Leoni,

    That's fine. If the thread is inactive too long it will become locked. If this happens, just make a new thread with the "Ask a related question" button.
  • In the meanwhile, I will put the suggestion of updating to a newer SDK as the proposed resolution.
  • Hi Leoni,

    Sometimes you need to clear the Mobile Phone Bluetooth Cache or Memory for the Bluetooth Services to be discovered. You can do that by closing the Bluetooth App then turning off then on your Mobile Phone Bluetooth.

    I have used PWM at SKDv1.40 and does not cause any problem. See, my project below.

    markelthinkslearnscreates.wordpress.com/.../

    When you make custom services from Bluetooth Developer Studio you need to modify it to work for CC2640R2F SDK.

    I agree with Marie to updated to the latest SDK as resolution.

    -kel