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.

CC2640 I2C poll acknowledge

Other Parts Discussed in Thread: CC2640

Hy,

I try to connect a SI7006 humidity/temperature sensor to a CC2640.

For readout, I need to send an I2C command and poll ack from slave to find out, if measurement is finished.

What is the best way to realize that in TI RTOS.

I tried "bspI2cWriteRead", but apparently, the read command does not evaluate ack from slave and does not retry read when NACK from slave.

Next try was to use the following code:

SENSOR_SELECT();  // send slave address
bspI2cWriteSingle(MEASUREMENTCOMMAND);  // start measurement
while(bspI2cRead(data, 2) == false)   // TODO: add timeout!
{
  ;
}
SENSOR_DESELECT();

Is that a good way to do it? It does not work, but it still might have other reasons.

Alternatively, the sensor has a "Hold master mode"

Is there an elegant way on realizing this on master side with TI RTOS?

Regards

Harald

  • Hi Harald,

    What is the behavior you see when probing the i2c bus during a transaction?

    Best wishes
  • So far, I have not connected my logic analyser to I2C, and I try to get round this. I have only one single prototype hardware, the only way to contact I2C is to solder to 0402 resistors.
    In your sample code, is there any example that polls ACK? On EEPROM write it should be quite similar?
    Regards
    Harald
  • So now I have it up and running. The easy way is to use the function bspI2cRead which returns 0 when a read is not acknowledged by the I2C slave.

    So what I do is:

        bspI2cWriteSingle(STARTMEASUREMENTCOMMAND);
        success = 0;
        delay_ms(14);  // this is the expected time to perform measurement
        while ((success == 0) && (errorCounter < 20000))
        {
            success = bspI2cRead(data, 3);  // try to read result
            if (success == 0) Task_sleep(80);
            errorCounter++;
        }
    This works just fine. Stil there is one pecularity:

    When observing on the Logic Analyser, I see two bytes on I2C bus when not successful:

    Why is still one byte read after having a NACK on the slave address?
     Anyway, it works just fine like this.

    Regards

    Harald