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.

RTOS/LAUNCHXL-CC2650: I2C Configuration

Part Number: LAUNCHXL-CC2650
Other Parts Discussed in Thread: SYSBIOS, TMP102, CC2650

Tool/software: TI-RTOS

Hello All,

I am using LAUNCHXL-CC2650, and want to use I2C for communicating with an accelerometer,

I am using DIO4 as SCL and DIO5 as SDA,

But i am not able communicate with the accelerometer, i am trying to read "Who AM I" register but not getting any value,

Whereas, when i tried the same with CC2640R2-Launch Pad the communication is done and i am able to read the values of "Who AM I" register of accelerometer

Also i searched for example code of i2c in my LAUNCHXL-CC2650 SDK as well as on TI's resource explorer but i was not able to find any example code for the LAUNCHXL-CC2650,

But the same when i doing with the CC2640R2-Launch Pad i am getting the values.

I have attached the code of I2C communication which i have created using empty project example from SDK, Please check and let me know if any Improvements 

Also i have attached the Board file and CC2650LaunchXL.c and .h , please help if any changes needed in these files

/*
* ======== i2ctmp006_cc26xx.c ========
*/

/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>

/* TI-RTOS Header files */
#include <ti/drivers/PIN.h>
#include <ti/drivers/I2C.h>

/* Example/Board Header files */
#include "Board.h"

#define TASKSTACKSIZE 512

Task_Struct tsk0Struct;
UInt8 tsk0Stack[TASKSTACKSIZE];
Task_Handle task;

/*
* ======== echoFxn ========
* Task for this function is created statically. See the project's .cfg file.
*/
Void taskFxn(UArg arg0, UArg arg1)
{
// unsigned int i;
uint16_t temperature = 0;
uint8_t txBuffer[1];
uint8_t rxBuffer[2];
I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;

/* Create I2C for usage */
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_400kHz;
i2c = I2C_open(Board_I2C, &i2cParams);
if (i2c == NULL) {
System_abort("Error Initializing I2C\n");
}
else {
System_printf("I2C Initialized!\n");
}

/* Point to the T ambient register and read its 2 bytes */
txBuffer[0] = 0x000F;
i2cTransaction.slaveAddress = 0x1D;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 2;


if (I2C_transfer(i2c, &i2cTransaction)) {
/* Extract degrees C from the received data; see TMP102 datasheet */
temperature = rxBuffer[0];


}


/* Deinitialized I2C */
I2C_close(i2c);
System_printf("I2C closed!\n");

System_flush();
}

/*
* ======== main ========
*/
int main(void)
{

Task_Params tskParams;
/* Call board init functions */
Board_initGeneral();

I2C_init();


/* Construct LED Task thread */
Task_Params_init(&tskParams);
tskParams.stackSize = TASKSTACKSIZE;
tskParams.stack = &tsk0Stack;
tskParams.arg0 = 50;
Task_construct(&tsk0Struct, (Task_FuncPtr)taskFxn, &tskParams, NULL);

/* Obtain instance handle */
task = Task_handle(&tsk0Struct);

System_printf("Starting the I2C example\nSystem provider is set to SysMin."
" Halt the target to view any SysMin contents in ROV.\n");
/* SysMin will only print to the console when you call flush or exit */
System_flush();

/* Start BIOS */
BIOS_start();

return (0);
}

//========================

Also i would like to tell that when i put break on "if (I2C_transfer(i2c, &i2cTransaction)) {" and when debug step by step the code directly jumps to "I2C_close(i2c);"

Please check and help me with i2c  communication on CC2650-LAUNCHPAD as the earliest.

Thanks and Regards

Utkarsh

  • 4237.CC2650_LAUNCHXL.h

    Sorry for the inconvenience Board Files For above Query attached here

  • Hi,

    when you hit I2C_close, what is the mode of the driver at this point? You can check this by watching the I2C object (add "i2cCC26xxObjects[0]" to the watch list). Inside this object, look for "mode".
  • Hello,

    Thank for Replying,

    As per your advice i have checked the mode and i am getting the mode as "I2C_MODE_BLOCKING".

    Also just to give a try as per the RTOS Drivers PDF i tried by changing the mode to  "Callback Mode" but the code is going to the line "temperature = rxBuffer[0];" but no value is read,

    I am not able to read any value,

    Please help with what should i do further,

    Also help me with SDK where i can get driver examples,

    Because i have Project Zero code for CC2650 LP and when i am including PWM or I2C example(Imported from Resource Explorer) in Project Zero code the files are not getting linked 

    Thanks and Regards

    Utkarsh