Other Parts Discussed in Thread: TMP117
主题中讨论的其他器件:TMP117
我使用 Tiva 开发板(TM4C123G)从 该 Adafruit 温度传感器读取 I2C。 我正在从温度传感器的寄存器0x0F 中读取一个2字节值。 它正常工作、预期值是我接收到的值(0x0117)、但 我想知道为什么在 我写入温度传感器地址的第一次写入位置后 SCL 线路保持低电平。 以下是我使用逻辑分析仪捕获的内容:

我正在使用的代码看起来正确、并且对于写入寄存器 然后读取两个字节来说非常简单:
// 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);
宏 WAIT_ON_I2C_BUS_BUS_BUSY 宏定义为:
#define WAIT_ON_I2C_BUS_BUSY(CHANNEL) if(I2CWaitOnMasterBusy(CHANNEL) == false) { EndCriticalSection(); return false; }
有人有什么想法吗?
