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/CC2650: CC2650 I2C interface ,I2cTx() ,I2cRx() ,Iam unable to write or read From sensor controller(Ambient Light Sensor)

Part Number: CC2650

Tool/software: TI-RTOS

Software :Sensor controller Studio.

Iam Using cc2650 launchpad,  Ambient Light Sensor(APDS-9306/APDS-9306-065),

Sensor controller is connected to cc2650, I want to write data and read the data through I2c my code is :->

i2cStart();

i2cTx(0x52);

i2cTx(I2C_OP_WRITE);

i2cRxAck(output.v);

i2cTx(0x00);

i2cRxAck(output.v2);

i2cTx(0x12);

i2cStop();

 is it ok ,or i have to aproach another way.. Iam a Fresher i know just basics ,please help anyone.

  • Hi Vamsi,

    I would suggest you look at the "I2C Light Sensor" example in Sensor Controller Studio as well as the code example found in the "I2C Master" chapter of the help section.

    For example, you would find that "I2C_OP_WRITE"  is simply saying if it is a read or write operation you expect to be doing, for this to make any sense you also have to "OR"-in the device address.

    Copy pasted from the help section:

    // Accelerometer (I2C address 0x86+W): Write X register address (0x04)
    i2cStart();
    i2cTx(0x86 | I2C_OP_WRITE);
    i2cTx(0x04);
    
    // If successful ...
    if (state.i2cStatus == 0x0000) {
    
        // Accelerometer (I2C address 0x86+R): Read X/Y/Z register values
        i2cRepeatedStart();
        i2cTx(0x86 | I2C_OP_READ);
        i2cRxAck(output.x);
        i2cRxAck(output.y);
        i2cRxNack(output.z);
    }
    i2cStop();
    
    // Handle errors, if any ...
    if (state.i2cStatus != 0x0000) {
        ... Handle errors ...
    } 

  • Hi M-W,
    I have tried this type of code for Ambient Light Sensor,but the i2c status is changed to 0x0001,after that it is not responding,
    could you please take a look on APDS 9306 sensor
  • Hi Vamsi,

    As this is the support aims to support TI devices, you would need to contact the manufacturer of the light sensor itself for support on how to use it.

    You getting a TX NACK back from the device suggest you are either not sending the expected data to the device (the address could for example be wrong) or the I2C bus is not working as intended. I suggest you start with sniffing the I2C lines and compare what is sent out to what is expected according to the sensor datasheet.