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.

CC1352P: I2C read transaction read delay

Part Number: CC1352P


We developed a custom board based on  CC1352P.

SimpleLink SDK 5.20.0.52.

Board is connected to an external sensor, I2C used for communication.

On I2C read, 500us is required after writing the register address and before reading the response ( See below sensor datasheet I2C command)

W/o delay response data is not valid.

There is no option to add such delay on SimpleLink I2C SDK. 

Any idea how this can be resolved?

  • Hi Amit,

    So, if I understood correctly, your sensor needs to wait 500us between the moment the I2C master writes to the register address and the moment the I2C slave can reply? This is a very particular behavior. Can you provide the datasheet for this sensor?

    Would it be possible to use two transfers, the first one being a just a dummy transfer with the register address, and the second one 500 us apart, to actually get the response?

    Or is this one scenario in which you would need some form of clock stretching, or something like that.

    The vast variety of I2C devices and implementations means that the I2C driver can only cover the most usual cases. If your I2C slave requires something particular, you need to modify the driver (which can be done of course).

    BR,
    Andres

  • Hi Andreas,

    I agree it is a very particular behavior.

    please check sensor manual page 12#:

    https://terabee.b-cdn.net/wp-content/uploads/2021/02/User-Manual-for-TeraRanger-Evo-single-point-distance-sensors-and-backboards.pdf

    1. How can I use two transfers ?  You mean always ignore first read  or something like :

    txBuffer[0] = regaddr;
    i2cTransaction.slaveAddress = device;
    i2cTransaction.writeBuf = NULL;
    i2cTransaction.writeCount = 0;
    i2cTransaction.readBuf = rxbuf;
    i2cTransaction.readCount = 0;

    status = I2C_transfer(_mi2c, &i2cTransaction);

    Delay(500) 

    txBuffer[0] = regaddr;
    i2cTransaction.slaveAddress = device;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 1;
    i2cTransaction.readBuf = rxbuf;
    i2cTransaction.readCount = 1;

    status = I2C_transfer(_mi2c, &i2cTransaction);

    2. How can I modify I2C driver? It is part of SimpleLink SDK  

    Amit

  • Hi again,

    Sorry for the late reply.

    I checked the datasheet and it’s not very descriptive. But my impression is that the only thing that you need to do is have two different transactions.

    1st transaction configuration:

    • Write one byte with the command value (0x00).
    • Read zero bytes.

    Use a clock or a timer to wait for 500 us, and then start the second transaction:

    2nd transaction configuration:

    • Write zero bytes
    • Read 3 bytes.

    So I don’t really think that it is necessary to modify the driver. Your code seems very similar to what I had in mind, except that you can’t have an I2C transaction with both the read count and the write count as zero.

    So probably, something like this:

    txBuffer[0] = 0x00; // Trigger reading command
    i2cTransaction.slaveAddress = deviceAddr;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 1;
    i2cTransaction.readBuf = NULL;
    i2cTransaction.readCount = 0;
    
    status = I2C_transfer(_mi2c, &i2cTransaction);
    
    Delay(500) 
    
    i2cTransaction.slaveAddress = deviceAddr;
    i2cTransaction.writeBuf = NULL;
    i2cTransaction.writeCount = 0;
    i2cTransaction.readBuf = rxBuffer;
    i2cTransaction.readCount = 3;
    
    status = I2C_transfer(_mi2c, &i2cTransaction);

    2. And just in case that you need to modify any driver, you need to import the driver files into your project. Otherwise the prebuilt drivers are used. By importing the driver into the project, you make sure that the driver is rebuilt each time.

    BR,
    Andres

  • Thanks, This resolved the issue!