完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
我想在PSoC编码SPICONtiON,但到目前为止还没有成功。我用ARDUIO检查我的从设备芯片是否工作。它有一个更简单的编码,例如“数据=SPI.Enter(0x00)”;同时发送和接收数据。我有很多问题理解如何在PSoC实现同样的功能。有没有一个代码片段可以启发我如何在PSoC接收和发送同一个主设备上的数据?(P.S.示例项目混淆)=()。谢谢您!
以上来自于百度翻译 以下为原文 I wanted to code SPI interface in PSoC but is so far unsucessful. I used Arduino to check if my slave device chips are working. It had a simpler coding such as "data=SPI.transfer(0x00);" to send and receive data at the same time. I had alot of problem understanding how the same function can be implemented in PSoC. Is there any one with a code snippet that can enlighten me on how I can receive and send data on the same Master device in PSoC? (P.S. Example projects are confusing =( ). Thank you! |
|
相关推荐
11个回答
|
|
在示例程序中提供了SPI程序。看看你是否能理解PRG图。
以上来自于百度翻译 以下为原文 There are SPI program in the example programm provided. See if you can make sense of the prgogram. |
|
|
|
这个线程可能是有用的。下载提交的文件并研究它。
HTTP://www. CyPress?COM/?APP =论坛和ID ID=2232和;RID=51593 快乐编码 以上来自于百度翻译 以下为原文 This thread may be useful. Download the files submitted and study it. http://www.cypress.com/?app=forum&id=2232&rID=51593 Happy coding |
|
|
|
|
|
|
|
嗨,快乐时光,
您可以参考与PSoC Creator一起航行的示例项目。在PSoC创建者组件目录中,右键单击SPI组件,并选择示例项目。 您可以根据您的要求修改项目并使其工作。 参考组件数据表将帮助您理解API的角色以及如何配置组件以满足您的需求。 当做, 高塔姆 以上来自于百度翻译 以下为原文 Hi HappyHour, You can refer to the example project which ships along with PSoC Creator. In PSoC Creator Component Catalog, right click on the SPI component, and select the Example project. You can modify the project according to your requirement and get it to working. Referring to component datasheet will help you understand the role of the APIs and how the component has to be configured to match your needs. Regards, Gautam |
|
|
|
我知道这是一个老线程,但对我来说,开始PFIG,我有同样的问题。这里的代码也可以帮助其他新手理解SPI API是如何工作的:
无符号char SPI(char OutDATA){unChar char结果=0;SpimthWrruteXDATA(OutDATA);而(SPIMAdReXTXSTATUSSUE()= = SPIMUSTSDSSPION);结果= SPIMULADRXDATA();返回结果;使用此代码,您可以以与其他CONTROLLER相同的方式发送和接收SPI数据。您还需要放置一个组件SPIM,在其中定义SPI规范(见附件)。只测试8位 它不使用中断,可能不是最快的,但它基本工作。 稻谷 未排放7.PNG 17.3 K 以上来自于百度翻译 以下为原文 I know this was an older thread but for me as starting PSoccer I had the same problems. Here is the code that also might help other newcomers understand how the SPI API works: unsigned char spi(char outdata){ unsigned char result=0; SPIM_WriteTxData(outdata); while (SPIM_ReadTxStatus()==SPIM_STS_SPI_DONE); result=SPIM_ReadRxData(); return result; } With this code you can send and receive SPI data in the same way as you are used to on other contollers. Apart from this code, you also need to place a component SPIM in which you define the SPI specs (see attachment). Only tested on 8 bits It does not use interrupts and might not be the fastest but it basicly works. Paddy
|
|
|
|
更新-对不起,我以前写的代码使用错误的while循环,因此有时会给出错误的返回值,这会更好。
UIT8 8 SPI(UIT8 OutDATA){UTI8结果=0;SPIMULIGRXXBuffER();SPIMMLIGETXXDATA(OUDATA);而(SPIMGEGTXBFFRESRESIZE()= 0);结果=(UIT8)SPIMURADRXDATA();返回结果;}帕特里克 以上来自于百度翻译 以下为原文 Update - sorry the previous code I write used the wrong while loop and therefor sometimes gave wrong return values, this works better.
|
|
|
|
类结构
(条件); 一直是误解的目标,正如我在许多地方所看到的(作为我自己的错误来源)。 在处理程序时,可以很容易地修改 (条件); 这真的不符合你的期望。 我喜欢一个建筑 无效等待(无效) { /不要做任何事(还) } … (条件)等待(); 这不仅说明了将要发生什么(不需要注释),而且额外地给了我一个点,在需要的时候安装一些后台进程。 快乐编码 鲍勃 以上来自于百度翻译 以下为原文 A construct like while(Condition); is always a target for misinterpretation as I have seen in many places (and used as a source for errors myself). While working on a program this can easily get modified to while(condition); DoSomething(); which will really not do what you expect. I like a construct as void Wait(void) {//Don't do anything (yet) } ... while(Condition) Wait(); which not only makes clear what is going to happen (no comment needed) but additionally gives me a point to install some background process when needed. Happy coding Bob |
|
|
|
也许我错过了什么,鲍伯,不会是未婚的时候…
我经常做以下工作 当(某个条件){ } 在循环中,我做其他事情,而不是等待(暗示机器不做任何事情) 而我在等待一个失败的条件。您的示例也允许在等待()中执行此操作。 你打过电话,也可以做其他事情。网不浪费任何MIPS。 那么我在你的帖子里错过了什么? 问候,Dana。 以上来自于百度翻译 以下为原文 Maybe I am missing something Bob, would not be the fiurst time..... I often do following - while ( some condition ) { } Inside the loop I do other stuff, not waiting ( implication machine not doing anything ) while I am waiting for a condition to fail. Your example also permits this in the wait( ) you have called, that could also be doing other stuff. Net is not wasting any MIPs. So what did I miss here in your post ? Regards, Dana. |
|
|
|
我只想指出Easi对小符号的误解,像是一个半结肠,它可能在那里,可能不是。通过一个虚假的缩进错误来增强——就像我最后一篇文章中的一个错误——可能导致心脏病。WAITE()的调用强调了程序员的意图,而且更容易。生态失调比半结肠ALONE。
使用具有{}的块语句和正确显示的缩进,具有相同的效果。当在块中执行一些动作时(因此:不只是等待条件变为真),块语句会更方便。 鲍勃 以上来自于百度翻译 以下为原文 I just wanted to point to the easi human misinterpretation of small signs like a semi-colon which might be there and might be not. Enhanced by a false indentation errors -like the one in my last post- can lead to heart deseases. The call of Wait() emphasises the programmers intention and is easier to recognize than a semi-colon allone. Using a block-statement with {} and a correct indentation as you showed has the same effect. When performing some actions within the block (so: not ONLY waiting for a condition to become true) the block statement will be more handy. Bob |
|
|
|
|
|
|
|
好的,谢谢。从今以后我要用:
当(0== SPIMUGEGTXBFFRESRSIZE()){/*doiNONO**/}; 而不是: 当(SPIMGEGTXBFEXRESIZE()==0){}; 功能相同,但更简单。 以上来自于百度翻译 以下为原文 Ok, thanks. From now on I will use : [size=11.199999809265137px]while (0==SPIM_GetRxBufferSize()) {/* Do_Nothing*/}; Instead of : [size=11.199999809265137px]while (SPIM_GetRxBufferSize()==0) {}; Functional the same but more foolproof. |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2069 浏览 1 评论
1826 浏览 1 评论
3639 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1760 浏览 6 评论
1510 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
508浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
358浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
410浏览 2评论
357浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
855浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 00:09 , Processed in 1.001431 second(s), Total 97, Slave 80 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号