Part Number: TMS570LC4357-EP
Hello,
I'm having trouble receiving humidity data from an HTU21D Sensor with my TMS570LC4357-EP using I2C. I have 10k pullup resistors on both of the I2C lines. Here is a (simplified) software flow:
Software Flow:
i2cInit();
while(1){
// Send request for data
i2cSetSlaveAdd(i2cREG2, sensorAddr);
i2cSetDirection(i2cREG2, I2C_TRANSMITTER);
i2cSetCount(i2cREG2, 1);
i2cSetStart(i2cREG2);
while(!i2cIsTxReady(i2cREG2)) {}
i2cSendByte(i2cREG2, humidityRegister);
// Receive data
i2cSetSlaveAdd(i2cREG2, sensorAddr);
i2cSetDirection(i2cREG2, I2C_RECEIVER);
i2cSetCount(i2cREG2, 3u);
i2cSetMode(i2cREG2, I2C_MASTER):
i2cSetStop(i2cREG2);
i2cSetStart(i2cREG2);
i2cReceive(i2cREG2, 3u, &humidityHolder[0u]);
// CRC the data and convert (already debugged and working as intended)
// delay for around ~1000ms
}
If I let the program run, it correctly reads in data once and then times out the next time I try to read data. However, stepping through the program results in unpredictable behavior (sometimes it works, sometimes it times out). I have verified the signals from the sensor and I am receiving correct data. I have tried this on multiple hardware setups all with the same result.
Please let me know if more information is needed, I am happy to provide it.
Thank you very much!