CC2640R2F: When i disable the "-DPTM_MODE" flag in .opt file, have any method i can change to PTM mode?

Part Number: CC2640R2F

My SDK version is : 3_40

IDE Tool: CCS 9.1.0

Using Example: examples\rtos\CC2640R2_LAUNCHXL\ble5apps\simple_serial_socket_server


Now we using the Flag:-DPTM_MODE to switch the cc2640r2f to run in PTM mode or non-PTM mode.

But now we must burn-in different files to switch PTM mode and non-PTM mode.

Does have any way that I build non-PTM mode, but can via some method to change to PTM mode?

I search in TI Forum, someone is discussing about the HCI_EXT_EnablePTMCmd. Seems if I pull-up a PTM gpio(GPIO_23), then I can send the HCI Command via UART?

Dose anyone knows the relevant information? Please share with me, thanks a lot!


  • Hello,

    I have assigned an expert to help with this query.



  • Dear Jan:

         Thanks for your help!

         If you have any ideas or solution, please tell me~

  • Hello:

    Have any update?


  • Danny,

    Please apologize for the delay.

    Does have any way that I build non-PTM mode, but can via some method to change to PTM mode?

    I don't have a ready project that performs runtime change, thus I can only give some pointers.

    Since the PTM_MODE is a #define, you would have to modify your project to instead have if clauses to actually include the specific constructs at runtime. CCS helps finding these constructs with the advanced search (Ctrl-H), which can locate the various instances and source files that reference this particular define.

    I imagine you already read the topics in our User's Guide below to include the other additional modules to your project. Like in the case above, there are a few other predefined symbols that could easily be encapsulated between if clauses to be enabled whenever needed:

    I will keep looking for any additional details that may help with this migration and report back in case I find anything relevant.

    Hope this helps,


  • Hi desouza:

    Thank you very much for the advice you gave me, I'm ongoing to implement following your advice.
    But now I suffer a very strange problem, and I want to consult you.

    Now I always set DPTM_MODE in the .opt file. I use a static global variable, and the value which is getting from the PIN_ID(6) by the API PIN_getInputValue();
    When I running ptm_mode, I will pull high PIN_ID(6) first. When I running non-ptm_mode, I will pull low PIN_ID(6).
    I use this variable to decide whether to run the SPP_doEnablePTMMode(). And i think the function SPP_doEnablePTMMode() is the key point whether can run into ptm_mode.

    But I suffer a strange problem.
    there are three situations, and I describe as bellow:
    1. I pull high PIN_ID(6), and expect to run into ptm_mode. After I testing using HCI command, and HCI command can work. And the xxx.hex size we burn-in is 278KB.
    2. I pull low PIN_ID(6), and expect can run into non-ptm_mode. I testing non-ptm_mode is fail. And the xxx.hex size we burn-in is 278KB.

    3. I direct using judge statement if(0), and the code will not running SPP_doEnablePTMMode(). I testing non-ptm_mode is successful. And the xxx.hex size we burn-in is 264KB

    Whether the strange problem is because my code size exceeds the "total nonvolatile memory"? cc2640r2f datasheet write total nonvolatile memory is 275KB.


    by Danny

  • Danny,

    I can't necessarily tell why your logic is not working, but since I never saw a development that dynamically switched between PTM and non-PTM modes, I wonder if it is necessary to reset the device to make this switch. I will consult with some colleagues. 

    The one aspect about .hex files is that their size on disk is not a reflection on their size in the device's memory. Hex files are text files in nature with additional characters such as the initial colon (:) sign, as well as CR/LF, etc.

    So, to know the size of the binary, you can refer to the linker .map file and see the usage as shown below.



  • Hi desouza:

    Thanks for your reply for correcting the flash allocation knowledge. About the PTM_MODE switch, if you have any news, please inform me.


    BR by Danny.

  • Dear desouza:

         In PTM Mode, we want to use the HCI command via UART to set BLE. We have to do RF testing.

         In non-PTM Mode, we want to connect to Mobile Phone via BLE, and we hope we can send some specific command between cc2640r2f and Mobile Phone.

         According to your cognition, can you give me some suggestions, what kind of Flag is not necessary and I can remove it? 

         My project has the following Flag:


    Thanks a lot.

    BR by Danny.

  • Danny,

    I consulted with some colleagues and they mentioned it should be alright to make the switch between the modes. I then found the thread below that describes a very similar scenario.Take a look at it and see if it brings some ideas.

    At this point, I would double check to see if anything in the file mentioned in the thread above (icall_hci_tl.c) has to be modified to make the PTM mode to be dynamically switched.

    I will keep looking for additional resources, but please give these a try.

    Hope this helps,