当我们等待您的答复时,这里有一些可能对您有帮助的信息。SPI是一个相当低的协议,它在主设备和从设备之间交换两个值:主设备向从属服务器发送一个值,同时从服务器向主机发送一个值。那就是全部!在硬件级别,您需要确保数据被放到总线上,并在主时钟和从机上读取相同的时钟转换。在微芯片世界中,这意味着在某些情况下获得CKP和CKE位以及SMP位。在上面,您需要在任何时间点定义值“均值”。通常是从属设备定义它需要什么信息以及它将发送什么信息。在这种情况下,你需要查看W25Q16 EEPROM数据表,以查看它期望什么值以及它将如何解释这些值。数据表显示,对于它所理解的每个命令,命令值(主将发送给从机;主机也将忽略此时从属服务器发送的任何内容)以及此后必须交换的任何值。例如,数据表的图8显示了“读”。结构。它显示了主控器发送指令,3个地址值(而忽略了从属服务器可能返回的任何内容),然后发送一个虚拟值(从属者将忽略此时间),而从属服务器从内存中返回该值。如果我是你,我会先确保SPI连接工作正常。你可以通过读取JEDEC ID或设备ID值来做这件事,因为你应该知道你将从奴隶那里得到什么。如果你不是这样的话,你需要解决这个问题,否则就没有其他的工作了,但是如果你能做到这一点,那么你就可以根据你的知识来执行你真正需要使用的操作。我不知道“fLIPTITE”函数是什么,以及为什么你要在“sEndoSpix8BIT”函数中解释“CMD”参数的位(我想你还是有一个bug),但是这对于一些非常简单的事情来说似乎是很有用的。苏珊
以上来自于百度翻译
以下为原文
While we wait for your reply, here is some information that might be helpful to you.
SPI is a fairly low level protocol that exchanges two values between a master and a slave device: the master sends a value to the slave at the same time as the slave sends a value back to the master. That is all it is!
At the hardware level you need to make sure that the data is being put onto the bus and being read on the same clock transitions by both the master and the slave. In the Microchip world, that means getting the CKP and CKE bits correct as well as the SMP bit in some cases.
Above that you need to define what the values "mean" at any point in time. Quite often it is the slave device that defines what information it needs and what information it will send back.
In your case, you need to look at the W25Q16 EEPROM data sheet to see what values it expects and how it will interpret those values. The data sheet shows, for each command that it understands, the command value (which the master will send to the slave; the master will also ignore whatever the slave sends back at this time), and any values that must be exchanged after that.
For example, Figure 8 of the data sheet shows a "read" instruction. It shows the master sending the instruction, 3 address values (all the while ignoring whatever the slave may be sending back) and then sending a dummy value (which the slave will ignore this time) while the slave sends back the value from memory.
All of that is the protocol that is define *above* the SPI protocol.
If I were you, I would start off by making sure that the SPI connection is working. You could do that by reading the JEDEC ID, or Device ID values as you should know what you will be getting back from the slave. If you are not then you need to sort out the problem or nothing else will work,
However if you can do that, then you can build on your knowledge to perform the operations you really need to use.
Looking at your code, you seem to be making life a bit hard for yourself. I have no idea what the 'flipbits' function does and why you are trying to interpret the bits of the 'cmd' parameter in the 'send_spi_8bits' function (and I think you have a bug there anyway) but this seems to be a lot of work for something that is really very simple.
Susan
当我们等待您的答复时,这里有一些可能对您有帮助的信息。SPI是一个相当低的协议,它在主设备和从设备之间交换两个值:主设备向从属服务器发送一个值,同时从服务器向主机发送一个值。那就是全部!在硬件级别,您需要确保数据被放到总线上,并在主时钟和从机上读取相同的时钟转换。在微芯片世界中,这意味着在某些情况下获得CKP和CKE位以及SMP位。在上面,您需要在任何时间点定义值“均值”。通常是从属设备定义它需要什么信息以及它将发送什么信息。在这种情况下,你需要查看W25Q16 EEPROM数据表,以查看它期望什么值以及它将如何解释这些值。数据表显示,对于它所理解的每个命令,命令值(主将发送给从机;主机也将忽略此时从属服务器发送的任何内容)以及此后必须交换的任何值。例如,数据表的图8显示了“读”。结构。它显示了主控器发送指令,3个地址值(而忽略了从属服务器可能返回的任何内容),然后发送一个虚拟值(从属者将忽略此时间),而从属服务器从内存中返回该值。如果我是你,我会先确保SPI连接工作正常。你可以通过读取JEDEC ID或设备ID值来做这件事,因为你应该知道你将从奴隶那里得到什么。如果你不是这样的话,你需要解决这个问题,否则就没有其他的工作了,但是如果你能做到这一点,那么你就可以根据你的知识来执行你真正需要使用的操作。我不知道“fLIPTITE”函数是什么,以及为什么你要在“sEndoSpix8BIT”函数中解释“CMD”参数的位(我想你还是有一个bug),但是这对于一些非常简单的事情来说似乎是很有用的。苏珊
以上来自于百度翻译
以下为原文
While we wait for your reply, here is some information that might be helpful to you.
SPI is a fairly low level protocol that exchanges two values between a master and a slave device: the master sends a value to the slave at the same time as the slave sends a value back to the master. That is all it is!
At the hardware level you need to make sure that the data is being put onto the bus and being read on the same clock transitions by both the master and the slave. In the Microchip world, that means getting the CKP and CKE bits correct as well as the SMP bit in some cases.
Above that you need to define what the values "mean" at any point in time. Quite often it is the slave device that defines what information it needs and what information it will send back.
In your case, you need to look at the W25Q16 EEPROM data sheet to see what values it expects and how it will interpret those values. The data sheet shows, for each command that it understands, the command value (which the master will send to the slave; the master will also ignore whatever the slave sends back at this time), and any values that must be exchanged after that.
For example, Figure 8 of the data sheet shows a "read" instruction. It shows the master sending the instruction, 3 address values (all the while ignoring whatever the slave may be sending back) and then sending a dummy value (which the slave will ignore this time) while the slave sends back the value from memory.
All of that is the protocol that is define *above* the SPI protocol.
If I were you, I would start off by making sure that the SPI connection is working. You could do that by reading the JEDEC ID, or Device ID values as you should know what you will be getting back from the slave. If you are not then you need to sort out the problem or nothing else will work,
However if you can do that, then you can build on your knowledge to perform the operations you really need to use.
Looking at your code, you seem to be making life a bit hard for yourself. I have no idea what the 'flipbits' function does and why you are trying to interpret the bits of the 'cmd' parameter in the 'send_spi_8bits' function (and I think you have a bug there anyway) but this seems to be a lot of work for something that is really very simple.
Susan
举报