完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我是SPI的新手,遇到了麻烦。我有一个PCB与PSoC 3试图沟通到NFR24L01+。对于PsoC Creator,我在项目中添加了一个SPIMAT,并有一个简单的循环,在我做了一个“SPIMUSTART()”之后,我尝试在从机上做一些简单的寄存器写/读。我有一个逻辑分析仪,显示我正在传输的SPI数据。好像我写的说寄存器0正在工作。我基本上做了一个“SPimeWrtiTxDATA(& lt;ADDR & Gt;32)”(寄存器写需要比特6是一个“1”来指示寄存器写),所以寄存器“0”如果值=32),那么我做另一个SPIMEWRITETXDATA(& Lt;Value& Gt;)将数据写入寄存器。到目前为止,很好,分析器显示了XFER。但是,当我尝试读取寄存器时,我发送“SPimeWrTiTxDATA(& lt;ADDR & GT)”(比特6对于读取是清晰的,因此只需要Reg ADDR),然后用BugUS数据编写另一个写(“SPimeWrTiTxDATA(0xFF)),这给从属节点返回返回值所需的时钟周期(用ANALY验证)。然后,我做一个“TEMP= SPIMAREDRADXDATA()”来读取我认为是从返回数据,但是返回的值不是预期的(分析器显示的也不是)。所以,我必须错过一些简单的步骤,然后我应该读取奴隶数据。
这是我的代码的一个简单例子。分析器输出的快照(附加) 我的猜测是我错过了一些Tx和/或RX状态检查,但我不知道什么和为什么? 有什么建议吗? 主体() UTIN ADDR,VALL; SPIMARSTATE(); 为(;;){ ADDR=32;/ /设置位6写入寄存器(即,01A AAAA)。AAAAA“是寄存器地址”。所以这里是“0”。 SpimWruteTxDATA(ADDR);// Tx ADDR从从设备 SpimWruteXDATA(0x1e);//写0x1e(注册0)。只是一个XFER测试,而不是尝试设置任何东西,但是)。 CyDelayUs(10U);/ /给XFER小的延迟 ADDR=0;/现在读取ReStIGER 0。读操作仅仅是地址(即,000 0A AAAA)。 SpimWruteTxDATA(ADDR);// Tx ADDR SPIMGWORKETXDATA(0xFF);//TX伪数据,以提供从其移位寄存器0内容所需的时钟周期。 CyDelayUs(10U);/ /给XFER小的延迟 Val= SpimaRead RxDATA();//我们应该看到0x1e,但是我们Val==0x00(分析器显示0x1e)。 } } 安非他命BMP 4.2兆字节 以上来自于百度翻译 以下为原文 I'm new to SPI and have run into a snag. I have a a PCB with a PSoC 3 trying to communicate to an nRF24L01+. With PsoC Creator, I have added an SPI mater to the project and have a simple loop where, after I do a "SPIM_Start()" I try to do some simple register write/read on the slave. I have a logic analyzer showing me the SPI data that is being transfered. It appears as though my write to say register 0 is working .. I basically do a "SPIM_WrtieTxData( Here is a simple example of my code.. and a snapshot of the analyzer output (attached) My guess is I'm missing some Tx and/or Rx status checks but I'm not sure what and why? Any suggestions? main() { uint8 addr, val; SPIM_Start(); for (;;) { addr = 32; // Set bit 6 to write to a register (i.e. 001a aaaa .. "aaaaa" is the register address). So reg "0" here. SPIM_WriteTxData(addr); // Tx addr to slave device SPIM_WriteTxData(0x1E); // Write 0x1E (to register 0 .. just an xfer test, not tryiing to set anything, yet). CyDelayUs(10u); // Give small delay for the xfer addr = 0; // Now read regsiter 0. A read operation is just the address (i.e. 000a aaaa) SPIM_WriteTxData(addr); // Tx addr to slave SPIM_WriteTxData(0xFF); // Tx bogus data to give slave the clock cycles it needs to shift out register 0 contents CyDelayUs(10u); // Give small delay for the xfer val = SPIM_ReadRxData(); // We should see 0x1E, but we val == 0x00 (analyzer shows 0x1E). } }
|
|
相关推荐
3个回答
|
|
|
|
|
|
这是我的“主C”(附件)。如果你需要整个项目让我知道。 这个代码没有什么特别的,我想做的就是让SPI写/读到/从NFR24L01+工作。由于我原来的帖子,我添加了一个等待SPimaRead RXSTATUS()的循环。这似乎已经解决了我现在遇到的问题,现在在读取SpimRead RxDATA()时看到返回值。但是,如果你能快速地看代码并提出建议,因为我仍然不确定我做的事情是正确的,我将非常感激。 M.C.Zip 1 K 以上来自于百度翻译 以下为原文 Here is my "main.c" (attached). If you need to whole project let me know. There is nothing special about this code, all I'm trying to do is get SPI write/reads to/from an nRF24L01+ to work. Since my original post, I have added a loop that waits for SPIM_ReadRxStatus(). This seems to have fixed the issue I was having and now see a return value when reading SPIM_ReadRxData(). But, if you could quickly look at the code and make suggestions, since I'm still not really sure I'm doing things correctly, I would greatly appreciate it.
|
|
|
|
fu6845463651 发表于 2018-11-19 11:41 请检查这个名为“SPILY设计”的代码示例,您将通过在创建的图像中显示此代码示例来获得此代码示例。 也许有帮助 以上来自于百度翻译 以下为原文 Can you please check this Code Example named as "SPI_Design" .You will get this Code example by going to this tab as shown in image attached in Creator- It may be helpful |
|
|
|
只有小组成员才能发言,加入小组>>
757个成员聚集在这个小组
加入小组2142 浏览 1 评论
1885 浏览 1 评论
3705 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1820 浏览 6 评论
1567 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
762浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
518浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
476浏览 2评论
434浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
1121浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-2-9 05:14 , Processed in 0.718680 second(s), Total 46, Slave 41 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191