完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
好啊。我正试图让一个主从使用18F2510两个工作。我从数据表理解这是如何工作的,但是我对SSPSTAT寄存器中的这5个可能的状态感到困惑(我指的是AN734页5)。由于奴隶只会接收和从不发送,我真的只对状态1和2感兴趣,但问题是:奴隶如何知道字节是地址还是数据?看来I2C硬件不知怎么知道字节是什么,因为它显然改变SSPSTAT寄存器后,接收字节。在开始检测,我可以理解它如何解释第一个字节作为一个地址(DyNoTa=0),所以下一个字节总是接收到是数据吗?我想,这是一个非常原始的问题,但它把我的炖肉弄糊涂了。
以上来自于百度翻译 以下为原文 Ok. I am trying to get a master-slave working using 18F2510 for both. I understand from the datasheet how this is supposed to work, but I'm confused on these 5 possible states in the SSPSTAT register (I'm referring to AN734 page 5). As the slave is only going to receive and never send, I'm really only interested in states 1 and 2, but heres the question: How does the slave know if the byte is an address or data? It appears as though the I2C hardware somehow knows what the byte is as it apparently changes the SSPSTAT register after the byte is received. After a start is detected, I can understand how it would interpret the first byte as an address (D_notA = 0), so is the next byte received always assumed to be data? This is, I guess, a really primitive question, but it is confusing the stew out of me. |
|
相关推荐
8个回答
|
|
它遵循它的状态机。它需要知道地址是否适合它。该地址将是启动后的第一个字节。
以上来自于百度翻译 以下为原文 It follows its state machine. It needs to know if the address is for it. The address would be the first byte after the start. |
|
|
|
正确的。该地址将是启动后的第一个字节。那么,如果在地址之后收到一个字节,状态机会自动知道接收到的下一个BTE不是一个地址吗?也许我不完全理解I2C。地址总是指设备吗?这将意味着所有后续字节可能是与设备相关联的数据或内部地址。这是正确的吗?
以上来自于百度翻译 以下为原文 Right. The address would be the first byte after the start. So, then, if a byte is received after the address, does the state machine automatically know that the next bte received is NOT an address? Maybe I just don't fully understand I2C. Does address always refer to the device? That would then mean that all following bytes might be data or internal addresses associated with the device. Is this correct? |
|
|
|
更高级的协议(每个字节意味着什么)完全由从属决定。您需要读取您试图访问的设备的数据表。启动后的第一个字节总是包含芯片地址和RW位,但有时也包含内部地址位。下一个或两个字节包含内部设备地址-寄存器地址,或EEPROM或Flash或RAM的内存地址。您不能编写一个通用的主I2C接口。你必须为你所说的设备写接口。
以上来自于百度翻译 以下为原文 The higher level protocol (what each byte means) is determined entirely by the slave. You need to read the datasheet for the device you are trying to access. The first byte after the START always contains the chip address and RW bit, but sometimes contains internal address bits as well. The next one or two bytes contain internal devices addresses - either register addresses, or memory addresses for EEPROM or Flash or RAM. You can't write a generic Master I2C interface. You have to write the interface for the device you're talking too. |
|
|
|
我明白了。我的问题不在于大师。它只关于奴隶。这两种设备都是相同的18F2510。所以,主发送开始,然后7位地址(让我们说0xB0)。由于RyNoTyw为0,这将告诉奴隶这是一个写操作。下一个字节既可以是寄存器地址,也可以是数据字节。我的问题是奴隶如何知道这个字节是什么。硬件是否理解第二个字节是内部地址或数据,还是我编码的固件的一部分?我假设,如果从接收到的字节不是从属地址,它将被解释为数据(关于I2C硬件)?如果是这样的话,那么只有奴隶知道第二个字节是内部地址/寄存器是固件告诉它。这是正确的吗?
以上来自于百度翻译 以下为原文 I undertsnad that. The question I have is not about the master. It is about the slave only. Both devices are identical 18F2510. So, master send start, then 7-bit address (let's say 0xb0). Since R_NOT_W is 0, this would tell the slave that this is a write operation. The next byte would either be a register address or a data byte. The question I have is about how the slave knows what this byte is. Does the hardware somehoe understand that the second byte received is an internal address or data or is that part of the firmware that I code? Am I to assume that if the byte received by the slave is not the slave address it is to be interpreted as data (with respect to the I2C hardware)? If that is so, then the only way for the slave to know that the second byte received is an internal address/register is for the firmware to tell it so. Is this correct? |
|
|
|
对不起,我在第一句中漏掉了“两个”。除了第一个字节上的地址匹配检测外,没有任何内置的字节序列。所以我的评论仍然是有效的- Slave决定序列。因为你在编程奴隶,所以你决定序列。这是你想要的任何东西。如果你需要一种寻址或命令来让奴隶知道该怎么做,那么你必须创建状态机(两边)来处理这个问题。
以上来自于百度翻译 以下为原文 Sorry - I missed the "for both" in the first sentence. Except for address match detection on the first byte, there's nothing built in that determines any byte sequence. So my comment is still valid - Slave determines the sequence. Since you're programming the slave - you determine the sequence. It's whatever you want it to be. If you need some kind of addressing or command for the slave to know what to do, then you have to create the state machine (on both sides) to handle that. |
|
|
|
好啊。我能做到。最后一个问题…我想:如果我必须处理字节序列(正如你所说的),我还必须以编程方式发送ACK,或者当接收字节时,从属设备会自动发送ACK吗?谢谢你的帮助。
以上来自于百度翻译 以下为原文 Ok. I can do that. Last question... I think: If I am having to take care of the byte sequence (as you put it) will I also have to programatically send the ack or will the slave automatically send the ack when it receives a byte? Thank you for the help. |
|
|
|
将ACK发送到接收的字节,从属发送ACK给接收的ACK。
以上来自于百度翻译 以下为原文 you send ACK to received bytes, slave sends ACK to the ones IT receives |
|
|
|
将ACK发送到接收的字节,从属发送ACK给接收的ACK。
以上来自于百度翻译 以下为原文 you send ACK to received bytes, slave sends ACK to the ones IT receives |
|
|
|
只有小组成员才能发言,加入小组>>
5160 浏览 9 评论
1998 浏览 8 评论
1927 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3170 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2225 浏览 5 评论
727浏览 1评论
612浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
501浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
626浏览 0评论
524浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 06:26 , Processed in 1.266494 second(s), Total 93, Slave 76 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号