Other Parts Discussed in Thread: TMP112,
Hi,I want to read the TMP112A's temperature of xwr6843aopEVM via i2c. The rend function is as follows:
float TMP_ReadTemp(I2C_Handle i2cHandle, uint8_t i2cSlaveAddress, uint8_t i2cSlaveRegAddress)
{
uint8_t txData[2];
bool retVal = false;
uint8_t rxData[2];
I2C_Transaction i2cTransaction;
int16_t digitalTemp = 2;
int32_t errCode;
/* Scan for the slave address */
System_printf ("22222222222 \n");
txData[0] = i2cSlaveRegAddress;
System_printf ("333333333 \n");
i2cTransaction.slaveAddress = i2cSlaveAddress;
System_printf ("44444444444 \n");
i2cTransaction.writeBuf = txData;
System_printf ("55555555555 \n");
i2cTransaction.writeCount = 1;
System_printf ("666666666666 \n");
i2cTransaction.readBuf = rxData;
System_printf ("777777777777 \n");
i2cTransaction.readCount = 0;
System_printf ("8888888888888 \n");
/* Writing to slave address */
retVal = I2C_transfer(i2cHandle, &i2cTransaction);
if (retVal == false)
{
System_printf ("I2C_transfer Failed \n");
}
else
{
/* Read from slave */
System_printf ("99999999999 \n");
i2cTransaction.slaveAddress = i2cSlaveAddress + 1;
i2cTransaction.writeBuf = txData;
i2cTransaction.writeCount = 0;
i2cTransaction.readBuf = rxData;
i2cTransaction.readCount = 2;
retVal = I2C_transfer(i2cHandle, &i2cTransaction);
if (retVal == false)
{
errCode = -1;
}
else
{
digitalTemp = (rxData[0]<<4) | (rxData[1]>>4);
if(digitalTemp > 0x7FF)
{
digitalTemp |= 0xF000;
}
}
}
return digitalTemp * 0.0625;
}
and before I use the api I2C_Handle,I2C_transfer()..,I have done I2C_Init(), I2C_Params_init(&i2cParams) and I2C_open(0, &i2cParams). The result when I debug is as follow:

It seems that when the code run to I2C_transfer(), it will stop. Is there anything wrong in my code about I2C?
Thx!
leiGong







