完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好。我是新的图片,我希望你们可以给我和一个有用的建议。我用PIC24FV32 KA301 I2C外设编辑寄存器POE PSE TPS23 84.i某处(?)下载了由Microchip制作的这个I2C.FUNC.C库。问题:当我使用I2C低保写(下图)时,CLK线在EkoPoLink中保持低。如果我评论一下,一切都很好。如果我不评论它,我必须结束我的阅读操作序列,因为他们没有实现这个EECAPROLLIN。我的问题:1。在所有事情都已经发生之后,使用确认轮询有什么意义呢?不使用返回值,因此在这种情况下不需要做这个函数。LDByTraceII2C返回已经从ACK状态生成的Error状态。那么什么是民意测验?2。即使它是无用的,它也不应该挂上CLK线。当我能选择2个不同的I2C奴隶连接到总线时,我可以看到使用这个函数,我必须知道它是哪一个。那样的话,我也会做类似的事情。那么,我的原因是什么时钟线保持低?我在看数据表,找不到答案。
以上来自于百度翻译 以下为原文 Hi. I am new to PICs, I hope you guys might give me and a helpful advice. I am using PIC24FV32KA301 I2C peripheral to edit registers of POE PSE TPS2384. I somewhere(?) downloaded this i2c_func.c library which is made by Microchip. Problem: When I use I2C low desnity write(shown below) CLK line is held low at EEAckPolling. If I comment it out, everything works fine. If I do not comment it out I must end my sequences with read operations, because they do not implement this EEAckPolling. /********************************************************************* * Function: LDByteWriteI2C() * * Input: Control Byte, 8 - bit address, data. * * Output: None. * * Overview: Write a byte to low density device at address LowAdd * * Note: None ********************************************************************/ unsigned int LDByteWriteI2C(unsigned char ControlByte, unsigned char LowAdd, unsigned char data) { unsigned int ErrorCode; IdleI2C(); //Ensure Module is Idle StartI2C(); //Generate Start COndition WriteI2C(ControlByte); //Write Control byte IdleI2C(); ErrorCode = ACKStatus(); //Return ACK Status WriteI2C(LowAdd); //Write Low Address IdleI2C(); ErrorCode = ACKStatus(); //Return ACK Status WriteI2C(data); //Write Data IdleI2C(); StopI2C(); //Initiate Stop Condition EEAckPolling(ControlByte); //Perform ACK polling return(ErrorCode); } /********************************************************************* * Function: EEAckPolling() * * Input: Control byte. * * Output: error state. * * Overview: polls the bus for an Acknowledge from device * * Note: None ********************************************************************/ unsigned int EEAckPolling(unsigned char control) { IdleI2C(); //wait for bus Idle StartI2C(); //Generate Start condition if(I2CSTATbits.BCL) { return(-1); //Bus collision, return } else { if(WriteI2C(control)) { return(-3); //error return } IdleI2C(); //wait for bus idle if(I2CSTATbits.BCL) { return(-1); //error return } while(ACKStatus()) { RestartI2C(); //generate restart if(I2CSTATbits.BCL) { return(-1); //error return } if(WriteI2C(control)) { return(-3); } IdleI2C(); } } StopI2C(); //send stop condition if(I2CSTATbits.BCL) { return(-1); } return(0); } My questions: 1. What is even the point of using acknowledgment polling after everything has happened already? The return value is not used, so there is no point of doing this function in this case. LDByteWriteI2C returns the errorstate already which is generated from ACK state. Then what is the point of the EEAckPolling? 2. Even if it is useless, it should not hang the Clk line. I can see using this function when I have option of 2 different I2C slaves connected to bus and I must know which one it is. In that case I would do something similar. So - what my cause the clock line to be held low? I was reading datasheet and could not find the answer. |
|
相关推荐
3个回答
|
|
|
|
|
|
嗨,我想EECAPROLLIN是用来感知当外围设备已经完成其内部写入,并准备接收新的数据。它将忽略投票(NACK),直到它准备好然后ACK。
以上来自于百度翻译 以下为原文 Hi, I think the EEackpolling is used to sense when the peripheral device has completed its internal write and is ready to receive new data. It will ignore the polls (NACK) until it is ready then ACK. |
|
|
|
你好,在消息1中的代码片段,不显示用于控制轮询的控制字节值。确保控制字节值是写地址:7位I2C地址和R/W位=0,用于确认轮询。如果EEPROM设备忙着内部写操作,则无所谓,将有。没有响应,给出NACK结果。但是如果EEPROM写入序列完成,I2C设备响应,那么读取地址必须遵循正确的读取顺序,读取至少一个字节,并以NACK和STEP序列结束。泥炭启动信号和二次传输,只需发送第一个字节后的停止信号,或者可以将内存地址与控制字节一起发送。迈西尔
以上来自于百度翻译 以下为原文 Hi, Code snippet in message #1, do not show what control byte value is used for acknowledge polling. Make sure the control byte value is Write address: 7-bit I2C address and R/W bit = 0, for acknowledge polling. If the EEPROM device is busy with internal write operation, it do not matter, there will be no response, giving NACK result. But if EEprom write sequence is completed, and I2C device respond, then a Read address must be followed with a proper Read sequence, reading at least one byte, and ending with NACK and Stop sequence from Master. Then, for acknowledge polling, there is no need for a repeat start signal and a second transfer, just send Stop signal after the first byte, or you may send memory address together with the control byte. Mysil |
|
|
|
只有小组成员才能发言,加入小组>>
5250 浏览 9 评论
2037 浏览 8 评论
1958 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3218 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2266 浏览 5 评论
790浏览 1评论
682浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
611浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
686浏览 0评论
584浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-29 10:58 , Processed in 1.085148 second(s), Total 50, Slave 44 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号