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/LAUNCHXL-CC1352R1: let me some advice about excuting command with i2c

Part Number: LAUNCHXL-CC1352R1

Tool/software: Code Composer Studio

this is what i have to do for excuting command like suspend,etc ,,.

For every write to the Command register, the following sequence is required:
1. Write 0x00 to Command register to clear the Response register.
2. Read Response register and verify contents are 0x00.
3. Write Command value from Table 5 into Command register.
4. Read the Response register and verify contents are now non-zero. If contents are still 0x00, repeat this step.
The Response register will be incremented upon the successful completion of a Command. If the Response
register remains 0x00 for over 25 ms after the Command write, the entire Command process should be repeated
from Step 1.

and this is my code (sensor is si1132,and i excute ALS_AUTO command)

I2C_init();
I2C_Handle i2cHandle;
I2C_Params i2cParams;

I2C_Params_init(&i2cParams);

i2cParams.transferMode = I2C_MODE_BLOCKING;
i2cParams.bitRate = I2C_100kHz;
i2cHandle = I2C_open(Board_I2C0, &i2cParams);

if (i2cHandle == NULL) {
while (1);
}

uint8_t rxBuffer[2];
uint8_t txBuffer[2];

/*read chipID*/
txBuffer[0]=0x00;
I2C_Transaction i2cTransaction;
i2cTransaction.slaveAddress = Si1132_ADDR;
i2cTransaction.writeBuf =txBuffer;
i2cTransaction.writeCount =NULL;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 1;
bool status = I2C_transfer(i2cHandle, &i2cTransaction);     --->read successful

if (status == false) {
while (1);
}

/*write 0x00 to Si1132_REG_COMMAND */
txBuffer[0]= Si1132_REG_COMMAND;
txBuffer[1]=0x00;
I2C_Transaction i2cTransaction1;
i2cTransaction1.slaveAddress = Si1132_ADDR ;
i2cTransaction1.writeBuf =txBuffer;
i2cTransaction1.writeCount =1;
sleep(1);
i2cTransaction1.readBuf = rxBuffer;
i2cTransaction1.readCount = NULL;

status = I2C_transfer(i2cHandle, &i2cTransaction1);

/*read Si1132_REG_RESPONSE*/
I2C_Transaction i2cTransaction2;
txBuffer[0]= Si1132_REG_RESPONSE;
i2cTransaction2.slaveAddress = Si1132_ADDR ;
i2cTransaction2.writeBuf =txBuffer;
i2cTransaction2.writeCount =NULL;
sleep(1);
i2cTransaction2.readBuf = rxBuffer;
i2cTransaction2.readCount = 1;

status = I2C_transfer(i2cHandle, &i2cTransaction2);   --> confrim  rxBuffer[0]=0x00

if (status == false) {
while (1);
}

/*write Si1132_ALS_AUTO command to Si1132_REG_COMMAND */
I2C_Transaction i2cTransaction3;
txBuffer[0]= Si1132_REG_COMMAND;
txBuffer[1]=Si1132_ALS_AUTO;
//I2C_Transaction i2cTransaction;
i2cTransaction3.slaveAddress = Si1132_ADDR;
i2cTransaction3.writeBuf =txBuffer;
i2cTransaction3.writeCount =1;
sleep(1);
i2cTransaction3.readBuf = rxBuffer;
i2cTransaction3.readCount = NULL;

status = I2C_transfer(i2cHandle, &i2cTransaction3);
sleep(1);

/*read*/
I2C_Transaction i2cTransaction4;
txBuffer[0]= Si1132_REG_RESPONSE;
i2cTransaction4.slaveAddress = Si1132_ADDR ;
i2cTransaction4.writeBuf =txBuffer;
i2cTransaction4.writeCount =NULL;
sleep(1);
i2cTransaction4.readBuf = rxBuffer;
i2cTransaction4.readCount = 1;

status = I2C_transfer(i2cHandle, &i2cTransaction4);   

--->Response register will be incremented upon the successful completion of a Command.

but its still 0x00 

i dont know what's the problem. 

i also saw oscilloscope but its zero 

  • If you are not getting the response you expect from the sensor I suggest that you contact Silicon Labs for support, and not TI, since they are making the sensor. You should send them a plot of your I2C communication, and they should be able to tell you if you are doing anything wrong with respect to what data the sensor expect. If you have problems related to the I2C interface of the CC1352, please let us know what data you are trying to transmit, and we can guide you to some SW examples.

    Siri
  • Hi,

    It is hard to say what you are doing wrong, but the "/*write Si1132_ALS_AUTO command to Si1132_REG_COMMAND */" part looks suspicious to me. The reason is that you are setting 2 bytes in the txBuffer, but you keep the write count as 1, which means the "ALS_AUTO" byte is not getting written to the device.