完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
我很难弄清楚如何设置UART接收中断。我设法得到了例子TX和RX代码,并修改了TX和RX OK,但我需要做以下,不知道如何设置这一点,以及如何在中断中访问变量。
我有2个应用程序。第一个方面如下: 当接收到每个字节时,RX中断中的状态机。 RX引脚不断切换。一个字节的引导和序列标记开始分组,所以我需要丢弃不想要的字节,直到检测到导入序列,然后将字节收集到缓冲器中,直到接收到正确的字节数为止。 我是否把RX缓冲区设置为最小,这样程序就在每个RX字节上产生中断,然后把我的状态机放到UARTHARRX.C中? 第二个应用更简单,因为它可以接收整个包BVEI之前,我需要处理任何东西。但这一个,我希望一个定时器被重置每次字节到达,然后20毫秒后,最后一个字节,定时器将到期,我设置了一个标志,以指示DATAN BUBF。另外,如果PSoC具有某种标准组件THA可以使用XON/XOFF进行分组接收,则可以改变分组结构。 数据包长度是动态的。 谢谢 以上来自于百度翻译 以下为原文 I am having trouble figuring out how to set up the UART Receive interrupt. I managed to get gthe example TX and RX code and modified for TX and RX ok but I need to do the following and not sure how to set this up and how to access variables in the interrupt. I have 2 applications. The first is as follows: State Machine within RX interrupt as each Byte is received. The RX pin is continuously toggling. A leading and sequence of bytes marks start of packet so I need to discard unwanted bytes until the lead-in sequence is detected and then gather bytes into a buffer until the correct number of bytes is received. Do I just set the RX buffer to minimum so the program generates interrupt on each RX byte and then put my state machine into UART_RX.C ? The second application is simpler in that it can receive the entire packet bvefore I need to process anything. But this one I want a timer to be reset every time a byte arrives and then 20ms after last byte the timer will expire and I set a flag to indicate DatainBuf. Alternately I can change packet structure if the PSOC has some sort of standard component tha can use XON/XOFF for packet reception. The packet lengty is dynamic. Thanks |
|
相关推荐
7个回答
|
|
在PSoC世界中,中断处理是相当容易的:
删除ISR组件并将其连接到中断信号。UD声明为 Cysi-ISrrPro(MyHandler);/ /原型声明 伊斯兰斯塔克斯特(MyHandler); CysIsR(MyHANDLE) { /清除中断源(检查UART状态,读取字符) } 我不喜欢在生成的文件中进行更改,尽管有明确的地方我可以这样做。但是切换到不同的设备可能会破坏我的变化。 你的追求constantlymonitoring信号和一个初始标记反应并不容易。你可以用一些额外的逻辑,看你的线(定时器/计数器),忽略所有的UART RX输入到初始标记发现。 鲍勃 以上来自于百度翻译 以下为原文 Interrupt handling is done quite easy in the PSoC world: Drop an isr-component and connect it to the interrupt signal. Ude declarations as CY_ISR_PROTO(MyHandler); // Prototype declaration isr_StartEx(MyHandler); CY_ISR(MyHandler() { // Clear source of interrupt (Check UART state, read off character) } I prefer not to make changes in the generated files although there are clearly marked places where I might do so. But a switch to a different device might spoil my changes. Your quest for constantly monitoring a signal and reacting on a initial marker is not as easy. You may watch your line with some additional logic (Timer / Counter) and ignore all UART-Rx inputs until initial marker found. Bob |
|
|
|
谢谢鲍伯,
我试图在创建的“C”和“H”文件中使用代码,然后意识到在主存C中设置ISR处理程序是容易的,并且简单地将向量声明给它,然后离开。这项技术是真正的“酷”相比,比特和字节和拨号周围我一直在用PIC微型。很好,我想做的很多事情都是由API处理的,我不必深入到注册中去。 我还有一个问题要问你。我在寻找阅读DS1820温度传感器11线组件并设法获得了一份来自维克托已在目录中的一个组成部分的一个项目(不是主目录)他的项目。 我怎么能让目录包含单组分为“柏”目录(他命名为“默认”,出现另一个选项卡”。我希望能够创建一个新的项目和使用组件。 干杯 戴维 以上来自于百度翻译 以下为原文 Thanks Bob, I was trying to play with code in the created "c" and "h" files and then realised it is easy to set up a isr handler in main.c and simply declare the vector to it and away we go. This technology is real "cool" compared the the bits and bytes and poking around I have been doing with PIC micros. It is great that much of what I want to do is handled by API and I don't have to dig down into registeres. I do have one other question for you. I was looking for a one-wire component for reading DS1820 Temperature sensors and managed to get a copy of a project from Victor which has a component in a catalog (not the main catalog) of his project. How can I get the catalog containing the 1-Wire component into the "Cypress" catalog (his is named "default" and appears as another Tab". I want to be able to create a new project and use that component. Cheers David |
|
|
|
因为每一个新版本的创建者,CATAOOG得到更新,我建议做如下:
创建包含所有您自己或外部创建的组件的文件夹。 当项目需要其中之一时,导入它。 要维护组件插入的文件夹,请查看与创建者-安装一起出现的“组件作者指南”。 鲍勃 以上来自于百度翻译 以下为原文 Because with every new version of Creator the cataög gets updated I would suggest to do as following: Create a folder that contains all your own or foreign created components. When a project needs one of those, import it. To maintain the folder the component gets inserted in, have a look into your "Component Author guide" that came with the Creator- installation Bob |
|
|
|
顺便说一下,有一种说法是“思维PSoC”,它试图解释在设计PSoC和其他嵌入式微芯片之间有巨大的差异(例如PICS)。
快乐编码! 鲍勃 以上来自于百度翻译 以下为原文 By the way, there is a saying "Thinking PSoC" which tries to explain that there is a huge difference between designing with PSoCs and other embedded micros (PICs for instance) Happy coding! Bob |
|
|
|
|
|
|
|
在第一次尝试中,创建自己的组件的过程可能是耗时的。由于PSoC的能力不会终止于100个预定义组件的布线,因此有很多值得学习的地方。PSoC5包含24个“通用构建块”(UDBS),您可以使用“硬件描述语言”(HDL)来编程。每个UDB包含一个“arethmetic和逻辑单元(ALU),可以通过编程来执行一些操作,两“先入先出(FIFO)和一堆逻辑。我可以向你保证,这不是通过学习缩写就完成了。
当我第一次接触PSoCs,我开始学习阅读使用的所有组件(和理解,有时是不容易的)的数据表,让他们去工作。 所以慢慢来。 鲍勃 以上来自于百度翻译 以下为原文 The process of creating your own component can turn out to be something time-consuming at the first try. There can be a lot to learn since a PSoC's capabilities do not end at the wiring of some 100 pre-defined components. A PSoC5 contains 24 "Universal Building Blocks" (UDBs) which you can program using a "Hardware Description Language" (HDL). Every UDB contains an "Arethmetic and Logical Unit" (ALU) that can be programmed to perform some operations, two "First-In-First-Out" (FIFOs) and a bunch of logic. I can assure you that it is not done just by learning the abbreviations. When I first got in contact with PSoCs I started learning to use all the components by reading (and understanding, which sometimes is not as easy) the datasheets and by getting them to work. So take your time. Bob |
|
|
|
这是我写的一个链接。这个组件主要包括编程,很少有硬件。需要一点更新。
鲍勃 以上来自于百度翻译 以下为原文 Here is a link to something I wrote www.cypress.com/. This component consists mostly of programming, very few hardware. Needs a bit of update. Bob |
|
|
|
只有小组成员才能发言,加入小组>>
753个成员聚集在这个小组
加入小组2096 浏览 1 评论
1841 浏览 1 评论
3662 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1781 浏览 6 评论
1530 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
547浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
404浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
430浏览 2评论
376浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
900浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-14 20:49 , Processed in 1.060539 second(s), Total 92, Slave 75 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号