Other Parts Discussed in Thread: TMP117
I'm using a Tiva Dev Board (TM4C123G) to read I2C from this AdaFruit temperature sensor. I'm reading a 2 byte value from register 0x0F of the temperature sensor. It works, the expected value is what I'm receiving (0x0117) but I'm wondering why the SCL line remains low after doing the first write where I write the address of the temperature sensor. Here's what I've captured with a logic analyzer:
The code I'm using seems correct and is fairly straightforward as far as writing the register and then reading the two bytes:
// Set up the slave address with write transaction MAP_I2CMasterSlaveAddrSet(i2cChannelInfo[channel].i2cBase, slaveAddress, false); WAIT_ON_I2C_BUS_BUSY(channel); // Store the command data in I2C data register MAP_I2CMasterDataPut(i2cChannelInfo[channel].i2cBase, registerAddress); WAIT_ON_I2C_BUS_BUSY(channel); // Start the I2C transaction MAP_I2CMasterControl(i2cChannelInfo[channel].i2cBase, I2C_MASTER_CMD_BURST_SEND_START); WAIT_ON_I2C_BUS_BUSY(channel); // Set the data direction to true since the I2C Master is initiating a read from the slave MAP_I2CMasterSlaveAddrSet(i2cChannelInfo[channel].i2cBase, slaveAddress, true); WAIT_ON_I2C_BUS_BUSY(channel); // Start receiving data in burst mode MAP_I2CMasterControl(i2cChannelInfo[channel].i2cBase, I2C_MASTER_CMD_BURST_RECEIVE_START); WAIT_ON_I2C_BUS_BUSY(channel); // Get the first byte *outputWord = (MAP_I2CMasterDataGet(i2cChannelInfo[channel].i2cBase) & 0xFF) << (byteOrder == I2C_LSB_FIRST ? 0 : 8); WAIT_ON_I2C_BUS_BUSY(channel); // Request the second (and final) byte MAP_I2CMasterControl(i2cChannelInfo[channel].i2cBase, I2C_MASTER_CMD_BURST_RECEIVE_FINISH); WAIT_ON_I2C_BUS_BUSY(channel); // Read the second byte of data *outputWord |= (MAP_I2CMasterDataGet(i2cChannelInfo[channel].i2cBase) & 0xFF) << (byteOrder == I2C_LSB_FIRST ? 8 : 0); WAIT_ON_I2C_BUS_BUSY(channel);
The macro WAIT_ON_I2C_BUS_BUSY macro is defined as:
#define WAIT_ON_I2C_BUS_BUSY(CHANNEL) if(I2CWaitOnMasterBusy(CHANNEL) == false) { EndCriticalSection(); return false; }
Anyone have any thoughts?