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/CC2640R2F: Sensor Controller Studio I2C Array read autoincrement

Part Number: CC2640R2F

Tool/software: TI-RTOS

Hi.

I'm trying to read 16 Bytes from an I2C sensor with a for Loop with no success, but if I read byte per byte it seems to work (I haven't got to the part of integrating the SCS to my Project Zero).

The I2C communication is ok, I already did a read to a register with a known value during the initialization.

But on the execution, I need to read 16 bytes, then I created a for loop but it returns a value for index 0, and always 255 for the other 15 indexes.

This efficient  way is not working

macro readQuat(){

    i2cStart();

    i2cTx(EM7180_ADDRESS | I2C_OP_WRITE); //W

    i2cTx(0x00); // 0x00 is the first position

    if (state.i2cStatus == 0x0000) {

        i2cRepeatedStart();

        i2cTx(EM7180_ADDRESS | I2C_OP_READ);

        for (U16 n = 0; n < QUAT_SIZE; n++) {

        i2cRxAck(output.EM7180quaternion[n]);
        }

}

i2cStop();

}

This NON-optimal way seems to be working

macro readByte(reg,result){

i2cStart();

i2cTx(EM7180_ADDRESS | I2C_OP_WRITE); //W

i2cTx(reg); //Reg = Rom version

if (state.i2cStatus == 0x0000) {

i2cRepeatedStart();

i2cTx(EM7180_ADDRESS | I2C_OP_READ);

i2cRxAck(result);

}

i2cStop();

}


// Main readByte(0x35,output.EM7180eventStatus); // reading clears the register if(output.EM7180eventStatus & 0x04) { // new quaternion data available //readQuat(); for (U16 n = 0; n < QUAT_SIZE; n++) { readByte(n,output.EM7180quaternion[n]); } }

The problem is that the second way I'm sending a stop between each byte and it's time-consuming, is not optimal.

Any idea of the reason for this behavior? And how to fix it?

Thanks and my best regards.