完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在使用一个简单主机(PSoC)和从设备的应用程序。
当我向Slave发出R/W命令时,我从I2C API中积累返回值, 然后对这0个(错误)进行评估,例如查找错误,实现错误处理。 如果我断开时钟或数据线,I2CM就被困在I2CM API中,一个名为CcLogStudi2的函数。 因此,净效应是为了降低整个应用程序。 正在使用的代码 无符号CARI2COK=0; I2COK =(I2CMYFSENSTART(SLAVADD,I2CMYORD)= 0)?1:0;/ /发送起始位I2COK=(I2CMYfFrEnter(MeMADR)=0)?I2COK + 1:I2COK;//发送命令读取TopCube I2COK=(I2CMYFSENtiFESTARESTART(SLAVADD,I2CMYRADE)= 0)?i2cok + 1:i2cok;/ /发送重复的起始位rxbuf [ 0 ] = i2cm_bread(i2cm_ackslave);//读低字节rxbuf [ 1 ] = i2cm_bread(i2cm_ackslave);//读高字节rxbuf [ 2 ] = i2cm_bread(i2cm_ackslave);//读PEC 代码工作正常,直到我断开时钟或数据线I2C奴隶,或如果失去权力的奴隶 发生。显然这应该算是I2C API实现的缺陷,无法处理 HW故障。我想一个办法将看门狗,但我认为一个好的选择。 这也是Creator的情况吗? 问候,Dana。 以上来自于百度翻译 以下为原文 I am using an application with a simple master (PSOC) and a slave device. When I issue R/W commands to Slave, I accumulate the return values from the I2C API, and then evaluate this for > 0 (errors), eg. looking for an error, to implement error handling. If I disconnect clock or data line the I2Cm gets stuck in a I2Cm API, a function called clockstretch2. So net effect is to take down entire application. Code being used - unsigned char I2Cok = 0; I2Cok = ( I2Cm_fSendStart( SLAVADD, I2Cm_WRITE ) == 0 ) ? 1 : 0; // Send start bit I2Cok = ( I2Cm_fWrite( memadr ) == 0 ) ? I2Cok + 1 : I2Cok; // Send command to read Tobject I2Cok = ( I2Cm_fSendRepeatStart( SLAVADD, I2Cm_READ ) == 0 ) ? I2Cok + 1 : I2Cok; // Send repeat start bit rxBuf[ 0 ] = I2Cm_bRead( I2Cm_ACKslave ); // Read low order byte rxBuf[ 1 ] = I2Cm_bRead( I2Cm_ACKslave ); // Read high order byte rxBuf[ 2 ] = I2Cm_bRead( I2Cm_ACKslave ); // Read PEC Code works fine, until I disconnect a clock or data line to I2C slave, or if a loss of power to slave occured. Clearly this should be considered a defect in I2C API implementation, inability to handle a HW failure. I suppose a workaround would be watchdog, but that I think is a poor choice. Is this also case for Creator ? Regards, Dana. |
|
相关推荐
1个回答
|
|
我曾经遇到过类似的问题,当我寻求一个通信接口,可以连接或不。令我惊讶的是,我发现在I2C规范中,没有什么像超时或定义的失败。到目前为止,我唯一能评估的是,一个(1)活着的奴隶似乎阻碍了I2C停滞不前。测试连接可以用I2CMysEnDestStar()返回,这将返回一个值!=当与奴隶的连接被破坏时为0。我没有找到在事务中捕获断线的方法。
鲍勃 以上来自于百度翻译 以下为原文 I had a similar problem once when I sought for a communication interface that could be connected or not. To my astonishment I found out that in the specs for I2C there is nothing like a timeout or a defined failure. The only workaround so far I could evaluate was that one (1) living slave seems to hinder the I2C from stalling. Testing the connection could be made with I2Cm_SendStart() which will return a value != 0 when the connection to the slave is broken. I did not find a way to capture a broken connection within a transaction. Bob |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2077 浏览 1 评论
1829 浏览 1 评论
3645 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1771 浏览 6 评论
1517 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
525浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
378浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
416浏览 2评论
363浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
873浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-1 17:33 , Processed in 0.864169 second(s), Total 77, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号