亲爱的TI官方:
我最近在开发TMS32C5535系列产品的时候发现了DSP的IIC死锁问题。还没找到有效的解决办法。
经过很多天的研究,我发现我遇到一个IIC的死锁问题,导致问题的原因可能是我设置的”CSL_I2C_MAX_TIMEOUT“ 设置太小的缘故。由于系统实时性的缘故我没办法使这个参数设置过大。
死锁总线表现为:SCL为高,SDA一直为低
现象:单片机采用硬件i2c读取E2PROM,当设备或者中断产生的时候,会有概率出现再无法与E2PROM通信,此时SCL为高,SDA一直为低
原因:当单片机正在和E2PROM通信,如果主正好发生打算发第9个时钟,此时SCL为高,而从开始拉低SDA为低做准备(作为ACK信号),等待主SCL变低后,从再释放SDA为高。如果此时正好单片机复位,主SCL还没来得及变低,直接变成高电平,此时从还在等待SCL变低,所以一直拉低SDA;而主由于复位,发现SDA一直为低,也在等待从释放SDA为高。因此主从都进入一个相互等待的死锁状态。
这是一些解决办法:
A problematic scenario can arise if the processor/I2C module gets reset while it is in the middle of mastering a transfer. In this scenario the external slave might be holding SDA low to transmit a 0 (or ACK). The end result is that the bus will hang. If the I2C tries to initiate a new transfer it will hit a "bus busy" error on some devices or "arbitration lost" on others. In this case it will not release SDA until it gets one or more falling edges on SCL.
There are a couple ways to recover from this scenario.1.For master devices that mux the SCL/SDA pins with GPIO, the easiest thingis to configure the pins for GPIO operation and toggle SCL until the slavereleases SDA. At this point you should be able to resume normaloperation.
2.Many master devices don't mux SCL/SDA with GPIO since the I2C I/O cellsare often special open drain cells. A workaround has been reported to workeven on these devices. By configuring the I2C for "free data format" and thenreading a byte the I2C will immediately start sending clocks to input data(rather than trying to send an address). This can be used to free up thebus.
3.Some slave devices can reset their I2C interface when the bus is hanging(e.g. the LTC4151, after 33 ms). Switch it on if that is not the defaultbehaviour.
For devices that actually boot from I2C you need to be careful about this scenario. Since the above workarounds rely on software they will not be possible if the device cannot boot! For this case you need to do something different. For example, if you can control the timing of the reset you could make sure you only reset the device when no I2C transaction is in progress. A different option would be to build your board such that the processor reset power cycles the I2C EEPROM/flash (or simply resets it, but most EEPROMs/flashes don't have a reset pin).
针对解放办法1. 我采用的设备的是TMS32C5535好像是没办法使IIC复用为GPIO。
针对解决办法2. 我尝试把IIC设置为"free data format"去读数据,但是我用示波器观察并没有产生SCL上时钟信号。
能帮我再分析看看还要什么好的解决办法吗?
Nancy Wang:
英文论坛看到一个帖子跟您遇到的情况类似,仔细阅读看看。
e2e.ti.com/…/ccs-tms320f28377d-i2c-free-data-format-is-not-active-when-sda-keeps-low
网上也搜到博客上总结了一些方法,可以看看是否有帮助。
blog.csdn.net/…/107745934
,
user6393475:
HI,Nancy Wang。非常感谢你的帮助,我已经根据您提供的英文论坛的帖子找到了解决办法。
,
Nancy Wang:
方便总结分享一下吗?谢谢!
,
user6393475:
方法在这里:
e2e.ti.com/…/how-to-recover-from-i2c-sda-stuck-low-on-dm646x
,
da qin zheng sheng:
很好
TI中文支持网


![AM6442: [IPC RPMSG] Message send to remote core 5 @ 16 end point truncated due to lack of space in vring buffer !!!-TI中文支持网](https://www.ti2k.com/wp-content/uploads/ti2k/DeyiSupport_DSP_pastedimage1753265713483v1.jpg)