完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我目前正试图使一个PIC24FJ1024GA606与一个WiBAND SPI Flash芯片IP252516JV(数据表为SPI Flash http://www. WangBo.com /RE…003222018 %20PLUS .pdf)。初始化后,我分配以下寄存器:用于数据交换,因为我知道发送消息的大小。和接收负载的预期大小,我使用两个变量——传输数据和接收ATAtiSE来驱动通信:通过读取和分配值到SPI1BUFL,我认为我应该能够保持SPI时钟运行。然而,时钟只在传输过程中工作。最后一个字节被发送的时候,SS引脚被拉高,时钟信号又回到空闲状态。为什么会这样呢?这是我第一次在SPI上工作,所以我很确定我错过了一些关键的事情。非常感谢大家的帮助。谢谢!
以上来自于百度翻译 以下为原文 Hello, I am currently trying to make a PIC24FJ1024GA606 communicate with a winbond SPI flash chip W25Q16JV (datasheet for SPI flash http://www.winbond.com/re...003222018%20plus.pdf). Upon initialization, I assign the following registers:SPI1CON1H = 0x0010; SPI1CON2L = 0x0000; SPI1STATL = 0x0000; SPI1BRGL = 0x0000; SPI1IMSKL = 0x0000; SPI1IMSKH = 0x0000; SPI1URDTL = 0x0000; SPI1URDTH = 0x0000; SPI1CON1L = 0x8220; For data exchange, since I know the size of the transmit message and the expected size of the receive payload, I use two variables - TransmitDataSize and ReceiveDataSize - to drive the communication: dataSentCount = 0; dataReceivedCount = 0; while( SPI1STATLbits.SPITBF == true ); //wait till transmit buffer clears up //example - TransmitDataSize is 2 if I am sending two bytes while (dataSentCount < TransmitDataSize) { if(SPI1STATLbits.SPITBF == true){ } else{ SPI1BUFL = *pSend; pSend += AddressIncrement; dataSentCount++; } } //example - ReceiveDataSize is 2 bytes if I am expecting two bytes of response payload while (dataReceivedCount < ReceiveDataSize){ if (SPI1STATLbits.SPIRBE == false){ *pReceived = SPI1BUFL; pReceived += AddressIncrement; dataReceivedCount++; } } By reading and assigning values to SPI1BUFL, I thought I should be able to keep the SPI clock running. However, the clock only works during transmit. The moment my last byte is sent, the SS pin is pulled high and the clock signal goes back to idle. Why is this the case? This is my first time working on SPI, so I am pretty sure I missed something crucial. Any help is greatly appreciated. Thanks! |
|
相关推荐
10个回答
|
|
回到学校学习SPI是什么以及它是如何工作的。
以上来自于百度翻译 以下为原文 Go back to school and learn what the SPI is and how it works. |
|
|
|
我真诚地希望。过去我还没有学会SPI。(我用MCC帮助我设置外围设备,但是在生成的代码中,我真的找不到时钟***纵的地方。它甚至没有显示我的SS引脚被拉低或高。你能给我一些更多的指针吗?谢谢。
以上来自于百度翻译 以下为原文 I would love to honestly. I have not learned about SPI in the past. :( I was using MCC to help me with setting up the peripheral, but in the generated code I couldn't really find where the clock is manipulated. It doesn't even show me where the SS pin is pulled low or high either. Can you give me some more pointers please? Thanks. |
|
|
|
我注意到闪存芯片的数据表坏了。重新连接:http://www. WangBo.com /r.%20RevD%.88122016PDF
以上来自于百度翻译 以下为原文 I noticed that the datasheet for the flash chip is broken. Reattaching: https://www.winbond.com/r...%20revd%2008122016.pdf |
|
|
|
这就是SPI运作的方式。时钟只在数据传输时运行,然后在最后一位传输后空闲。如果您查看Flash数据表中的波形,您将看到这一点。为什么要一直运行时钟?你需要设置的一些东西是时钟极性,当数据与时钟相比变化时,还有一些我记不起来。
以上来自于百度翻译 以下为原文 This is the way SPI operates. The clock only runs when the data is being transferred, then goes to idle after the last bit is transmitted. If you look at the waveform in the flash data sheet you will see this. Why do you want to run the clock all the time? Some things you need to set up are the clock polarity, when the data changes in comparison to the clock, and some other I cannot remember. |
|
|
|
谢谢!我只希望时钟在传输过程中运行,但是它似乎运行得不够长,我无法在DO上检索响应消息。我连接了一个逻辑分析仪来监视DI、DO和CLK,就像数据表中的波形一样,每当DI上传输字节时,我就可以看到CLK切换。然而,在DI结束传输之后,CLK停止切换。对于我在迪村上发送的指令,我期待着对DO的响应(例如,数据表中的读取数据03h指令),但是由于CLK返回空闲,所以我不能在DO上检索任何内容。
以上来自于百度翻译 以下为原文 Thanks! I only want the clock to run during transfer, but it seems like it doesn't run long enough for me to retrieve the response message on DO. I hooked up a logic analyzer to monitor DI, DO, and CLK, and just like the waveforms in the datasheet, I was able to see the CLK switching whenever the bytes are being transferred on DI. However, after the transfer ended on DI, the CLK stopped switching. For the instruction I sent on DI, I am expecting a response on DO (for instance, the Read Data 03h instruction in the datasheet), but since the CLK goes back to idle, I am not able to retrieve anything on DO. |
|
|
|
嗨,SPI通信是数据的双向交换,传输的比特数==接收的比特数==时钟脉冲数。无论你使用的所有接收到的字节,或者发送什么值,都不会被接收器使用,你可以在你的代码中确定,但是SPI主机必须将字节推送到发送寄存器中,对于所有要交换的字节,也必须读到空的接收寄存器,对于每一个交换的字节,否则会出现溢出错误。有运行SPI的可选模式,如框架模式,保持时钟信号始终运行,用字节或字同步。在SS线上,但你的SPI闪存设备将无法在这些模式下工作。在维基百科上有相当好的SPI解释,你可以从那里开始,直到你了解它是如何工作的。对于PIC24设备,有家庭参考手册部分的所有外设,用MO。重新解释和示例材料,而不是数据表中的列表。有关FRM部分的列表,以及下载链接,都在Microchip产品网页中用于您的设备。迈西尔
以上来自于百度翻译 以下为原文 Hi, SPI communication is Bidirectional Exchange of data, Number of Bits Transmitted == Number of Bits Received == Number of Clock pulses. Whether you use all bytes Received, or What value is transmitted for bytes that will not be used by Receiver, you may determine in your code, but SPI master have to push bytes into Transmit register, for all bytes to be exchanged. Also must Read to Empty Receive register, for every byte exchanged, otherwise there will be Overflow error. There are alternative modes of running SPI, like Framed mode, that keep Clock signal running all the time, with byte or word synchronization on SS line, but your SPI Flash memory device will not be able to work in those modes. There is reasonably good explaination of SPI on Wikipedia, you may start there, until you understand how it work. For PIC24 devices, there is Family Reference Manual sections for all peripherals, with more explaination and example stuff, than what is in the Datasheet. List over relevant FRM sections, and download links, are in the Microchip Product Webpage for your device. Mysil |
|
|
|
SPI闪存在读操作的方式是需要发送00的虚拟数据来将数据时钟输出到DO引脚。例如,对于一个Flash Read命令。1)选择第二部分(发送读取命令BYTE3)发送地址LSB4)发送地址MSB6)发送尽可能多的“哑”00字节作为您想要接收的数据字节7)取消选择PARON步骤(6)还需要读取Flash数据OU。在CPU上的SPI寄存器的T,并将它们存储在一个数组中。
以上来自于百度翻译 以下为原文 The way the SPI flash work on a read is you need to send dummy data of 00 to clock out the data to the DO pin. For example, for a flash read command. 1) Select the part 2) Send the Read command byte 3) Send the address l*** 4) Send the address middle byte 5) Send the address m*** 6) Send as many "dummy" 00 bytes as data bytes you want to receive 7) Deselect the part on step (6) you also need to read the flash data out of the SPI register on the CPU and store them in an array. |
|
|
|
哦,这有道理!第6步是我错过了什么。我认为波形中的XS意味着我不需要做任何事情。我实现了虚拟字节,现在事情正在运作。非常感谢你们。再次,为这些愚蠢的问题道歉。
以上来自于百度翻译 以下为原文 Oh, that makes sense! Step 6 is what I am missing. I thought the Xs in the waveforms mean I don't need to do anything. I implemented the dummy bytes and now things are working. Thank you guys so much. Again, sorry for the stupid questions. |
|
|
|
当数据与时钟相比变化时,Tx和Rx是独立的设置。
以上来自于百度翻译 以下为原文 When the data changes in comparison to the clock, on Tx and Rx are separate settings. |
|
|
|
我发现,如果将字节数作为虚拟数据发送,则使用范围或有限深度逻辑分析器调试更容易一些。
以上来自于百度翻译 以下为原文 I find it a little easier to debug with a scope or limited depth logic analyzer if I send the byte number as the dummy data. |
|
|
|
只有小组成员才能发言,加入小组>>
5208 浏览 9 评论
2017 浏览 8 评论
1943 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3189 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2244 浏览 5 评论
758浏览 1评论
646浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
564浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
657浏览 0评论
556浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-10 04:55 , Processed in 1.385792 second(s), Total 94, Slave 78 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号