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.

[参考译文] TMS570LC4357-EP:与HTU21D温度/湿度传感器连接时出现I2C问题

Guru**** 2471610 points
Other Parts Discussed in Thread: TMS570LC4357-EP

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1100288/tms570lc4357-ep-i2c-problems-when-interfacing-with-htu21d-temp-humidity-sensor

部件号:TMS570LC4357-EP

您好,

我在使用I2C的TMS570LC4357-EP从HTU21D传感器接收湿度数据时遇到问题。 我在两条I2C线路上都有10k上拉电阻。 以下是(简化的)软件流:

软件流:

i2cInit();

而(1){

  //发送数据请求

  i2cSetSlaveAdd(i2cREG2, sensorAddr);

  i2cSetDirection (i2cREG2,I2C_transmitter);

  i2cSetCount (i2cREG2,1);

  i2cSetStart (i2cREG2);

  while (!i2cIsTxReady (i2cREG2)){}

  i2cSendByte (i2cREG2,humidityRegister);

  //接收数据

  i2cSetSlaveAdd(i2cREG2, sensorAddr);

  i2cSetDirection (i2cREG2,I2C_RECEIVER);

  i2cSetCount (i2cREG2,3U);

  i2cSetMode (i2cREG2,I2C_MASTER):

  i2cSetStop (i2cREG2);

  i2cSetStart (i2cREG2);

  i2cReceive(i2cREG2, 3U,&humidityHolder[0U]);

  //对数据进行CRC和转换(已调试并按预期工作)

  //延迟约~1000ms

}

如果让程序运行,它将正确读取一次数据,然后在下次尝试读取数据时超时。 但是,逐步执行该程序会导致不可预测的行为(有时它起作用,有时它超时)。 我已验证传感器的信号,并且正在接收正确的数据。 我在多个硬件设置上都尝试了此操作,结果相同。

如果需要更多信息,请告诉我,我很乐意提供。

非常感谢!