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.

TMS320F28377D: I2C sensor failure detection

Part Number: TMS320F28377D
Other Parts Discussed in Thread: C2000WARE

Hello,

I have the following code to begin i2C communication which was extracted from the library provided 

the MCU is getting stuck on the second while loop(I2C_STS_REG_ACCESS_RDY)  if you have wrong slave address or if the sensor is faulty (due to power loss / or defective part) . otherwise it work well.

could you please advise how to detect sensor failure.

void I2CbeginTransmission(uint16_t slaveAddr)
{
    while (I2C_getStopConditionStatus(I2CA_BASE));
    I2C_setConfig(I2CA_BASE, (I2C_MASTER_SEND_MODE|I2C_REPEAT_MODE));
    I2C_setSlaveAddress(I2CA_BASE, slaveAddr);
    I2C_sendStartCondition(I2CA_BASE);
    while(!(I2C_getStatus(I2CA_BASE) & I2C_STS_REG_ACCESS_RDY));
}

Best Regards,

M.

  • Hi M,

    Which software example are you using? One within C2000WARE?

    C:\ti\c2000\C2000Ware_4_01_00_00\driverlib\f2837xd\examples\cpu1\i2c

    the MCU is getting stuck on the second while loop(I2C_STS_REG_ACCESS_RDY)  if you have wrong slave address or if the sensor is faulty (due to power loss / or defective part) . otherwise it work well.

    Checking if a NACK was received or having a timeout in the while loop may be effective in this case.

    Best,

    Kevin

  • Hi Kevin, 

    Thank you for your reply.

    yes, I used C2000ware examples  :  see I2CBusScan , i2c_ex4_eeprom_polling.c

    there is similar  while loop but it doesn't lock when checking invalid address.

    while(!(I2C_getStatus(base) & I2C_STS_REG_ACCESS_RDY));

    as you suggested I'll use timeout in the while loop.

    Best Regards,

    Mahir

  • Hi Mahir,

    OK, I see now. If I remember correctly, that while loop will exit once the slave address as been sent and an ACK has been received. So if it doesn't get sent properly or a NACK occurs, then you'll need some mechanism to break out of it (timeout or NACK checking).

    Best,

    Kevin