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.

CCS/CC2640: How to read data from I2C and update data in BLE service

Part Number: CC2640
Other Parts Discussed in Thread: CC2650, , TMP112, CC2650STK, BLE-STACK, TMP007

Tool/software: Code Composer Studio

Hello,

I'm working on cc2640 and want to read temperature from a TMP112 temperature sensor which is communicating through I2C. I'm using the CC2650 LP and design the prototype based on Project Zero example. I create a service and a characteristic for temperature data reading. I have realize the temperature reading in the RTOS. Could anyone tell me how to read the temperature in the project app and update the data in my service?

Thanks a lot!

  • Hello,

    I would recommend one of the I2C examples from TI-RTOS with project zero.

    For example if you TI RTOS 2.20.02.18 installed then you can reference this example (it uses the STK, but the same concept applies to launchpad)

    file:///C:/ti/tirtos_cc13xx_cc26xx_2_20_01_08/examples/TI/CC2650STK/i2ctmp007/README.html
  • Hello Sean,

    Thank you for your quick response. I can print the I2C temperature value on the console, but the problem is that I can not send this data to BLE service. My question is more like: how can I run a I2C task in the BLE task?

    Best,
    Jianlin
  • Hi Sean,

    I have the same problem stated by Jianlin. I was wondering whether you can follow up on it?

    Thank you so much!
  • Hello,

    In order to communicate with the BLE-stack a TI-RTOS task must be icall enabled. There is a section that covers adding ICALL functionality to an existing task here:

    However, what I recommend is the opposite approach. Start with a project that already has BLE in it (i.e. project zero) and add the I2C code to that task.

  • Additionally, we will have an example of reading I2C sensor data from a tmp007 and sending over BLE. it is coming soon within our simplelink academy module on dev.ti.com/tirex/#/. Stay posted.
  • The temperature reading SimpleLink Academy Lab that Sean referred to is now online! You can find it in SimpleLink Academy in CCS Resource Explorer or at dev.ti.com in the Software-> SimpleLink CC2640R2 SDK - v:1.30.00.25 -> SimpleLink Academy folder. It is called Bluetooth low energy + Sensors BoosterPack. Please try it out and let us know if you have any further questions!

  • Thank you Rachel! I will definitely look at that example.  

  • Hello Rachel,

    I have a question on the thread management regarding to this example. In the example, the as temperature is changing, which means the characteristic value is changing. In this case, will the char_changeCallBack function continuously catch the latest temperature value or the temperature measurement thread will only be activated when the client is calling for reading the value?

    Thanks,
    Jianlin
  • Hi Jianlin,

    The SimpleLink Academy lab module only shows creating a new service and characteristic with read properties. So it is only updated when the device receives a read request. In order to continuously update, you would need to enable notifications. If you need help with enabling notifications, you can see Task 5 in the Custom Profile Lab

  • Hello Rachel,

    I have posted another question which is on the using 32khz crustal-less model. I'm also using the project zero example on CC2650 LP. I followed the "Running Bluetooth® low energy on CC2640 Without 32 kHz Crystal" guidance.
    However, when I got the following errors when I modified the Project_Zero_APP project:

    #1965 cannot open source file "ti/drivers/power/PowerCC26XX.h" rcosc_calibration.c /ProjectZeroApp_CC2650LAUNCHXL/Startup line 54 C/C++ Problem
    #20 identifier "CCFG_MODE_CONF_VDDR_TRIM_SLEEP_TC_M" is undefined ccfg_app_ble_rcosc.c /ProjectZeroApp_CC2650LAUNCHXL/Startup line 461 C/C++ Problem
    #20 identifier "CCFG_MODE_CONF_VDDR_TRIM_SLEEP_TC_S" is undefined ccfg_app_ble_rcosc.c /ProjectZeroApp_CC2650LAUNCHXL/Startup line 461 C/C++ Problem
    #20 identifier "CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM_M" is undefined ccfg_app_ble_rcosc.c /ProjectZeroApp_CC2650LAUNCHXL/Startup line 460 C/C++ Problem
    #20 identifier "CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM_S" is undefined ccfg_app_ble_rcosc.c /ProjectZeroApp_CC2650LAUNCHXL/Startup line 460 C/C++ Problem
    #20 identifier "PowerCC26XX_calibrate" is undefined CC2650_LAUNCHXL.c /ProjectZeroApp_CC2650LAUNCHXL/Startup line 102 C/C++ Problem
    #20 identifier "PowerCC26XX_Config" is undefined CC2650_LAUNCHXL.c /ProjectZeroApp_CC2650LAUNCHXL/Startup line 99 C/C++ Problem
    #20 identifier "PowerCC26XX_standbyPolicy" is undefined CC2650_LAUNCHXL.c /ProjectZeroApp_CC2650LAUNCHXL/Startup line 101 C/C++ Problem
    gmake: *** [Startup/CC2650_LAUNCHXL.obj] Error 1 ProjectZeroApp_CC2650LAUNCHXL C/C++ Problem



    1.Could you please tell me how to set the correct configuration and enable RCOSC_LF?

    2.Besides, I will use the 4*4 CC2640 package, what board configuration should I change? I found almost every example is based on 7*7 package chip. Could you please provide an example on the small package chip?

    Thanks,
    Jianlin