1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
我使用PSoC 3 UART函数,在简单的应用程序中获取数据似乎有问题。 如果我使用一个终端窗口,输入文字,一切工作正常但如果iprogrammatically发送一个字符串,它的FIFO的包裹和LF风在缓冲区中的第一个字符。 我要做的就是读状态时看到的字符是(uart_1_rx_sts_fifo_notempty),然后进入一个循环的例子几乎相同的datasheet.that把所有的字符直到cr-lf。. 我已经把uart_1_getrxbuffersize()是否超过一个字符来了但是我看到不止一次。 有什么想法可以阻止我进行黑客攻击和猜测吗? 当做, 尼克 以上来自于百度翻译 以下为原文 Hi, I'm using the PSoC 3 UART function and seem to be having problems getting the data in a simple application. If I am using a terminal window to type characters, everything works fine but if I programmatically send a string, it appears that the FIFO wraps around and the LF winds up in the first character in the buffer. What I tried to do is read the status to see when a character comes in (UART_1_RX_STS_FIFO_NOTEMPTY), then go into a loop almost identical to the example in the datasheet.that takes all the characters until the CR-LF. . I have put a UART_1_GetRxBufferSize() to see if more than one character has arrived but I never see more than one at a time. Any ideas to prevent me from days of hacking and guessing? Regards, Nick |
|
相关推荐
11个回答
|
|
当您为我们提供更多的设置和选择的属性时,清除您的问题将非常有帮助。你能创建一个“工作空间包”并在这里上传(不使用Chrome,不工作)?
你的两个原则通常都起作用,所以事业必须在不同的地方。 鲍勃 以上来自于百度翻译 以下为原文 When you provide us a bit more with settings and selected properties it would be rather helpful to clear your issue. Can you create a "Workspace Bundle" and upload it here (NOT USING chrome, won't work)? Both of your principles usually do work, so the cause must be at a different place. Bob |
|
|
|
鲍勃,
是的,我会上传它,但是后来我做了一个实验,我只发送了4字节(默认RX缓冲区大小)到设备上,没有发现任何问题。它在10个字节中得到了4个字节的10倍。你必须配置你的接收缓冲区来考虑最坏的情况吗? 尼克 以上来自于百度翻译 以下为原文 Bob, Yes, I'll upload it but I have subsequently done an experiment where I sent only 4 bytes (default Rx buffer size) to the device and didn't see any problems. It got all 4 bytes 10 times out of 10. Do you have to configure your receive buffer size to account for worst case? Nick |
|
|
|
UART先进先出正好是4字节深,这可能是测试的原因。当设置大于4的RX缓冲区大小时,会生成内部中断,这样您就不能捕获非空FIFO状态或空RX寄存器,只检查缓冲区大小就可以工作。
在这一点上(你不是第一个有问题在这里)我通常建议写一个中断驱动的环形缓冲区来处理传入的字符。 鲍勃 以上来自于百度翻译 以下为原文 The UART FIFO is exactly 4 bytes deep, that might be the reason why that test worked. When you set the Rx buffersize larger than 4 an internal interrupt is generated, so that you will not be able to catch a non-empty FIFO-state or an empty Rx register, only checking the buffersize will work. At this point (you are not the first having problems here) I usually suggest to write an interrupt-driven circular buffer to handle incoming characters. Bob |
|
|
|
鲍勃,
谢谢,这很有道理。我对内部中断有点困惑。我不需要编写一个特殊的IpUPT处理器,还是我呢? 我可以简单地设置缓冲区大小类似的48,然后做一个uart_getrxbuffersize()电话确定何时检索数据为iPass通过主回路? 尼克 以上来自于百度翻译 以下为原文 Bob, Thanks, that makes sense. I'm a little confused about the internal interrupt. I don't have to write a special interupt handler or do I? Can I simply set the buffer size to something like 48, then do a UART_GetRxBufferSize() call to determine when to retrieve the data as I pass through the main loop? Nick |
|
|
|
确切地。
(UARTHEGETRXBuffelsiz()) { 在这里使用适当的UART API } 博伊布 以上来自于百度翻译 以下为原文 Exactly. while( UART_GetRxBufferSize() ) { RetrieveOneCharacter(); // Use the appropiate UART API here } Boib |
|
|
|
鲍勃,
谢谢一百万。那效果好多了。关键是使用getrxbuffersize反对检查rxstatus。我偶尔还是会想一个字符但是很少,可以调出来。我的应用是一个小型的RS485网络。看来这4字节的缓冲区是一个人类敲命令从终端好但我需要能够做bothterminal和串行指令和这部作品都很好地。我有一个类似的问题与USBUART好像getrxbuffersize是近亲的u***uart_getall()命令。 为了简化问题,我会在while循环的getrxbuffersize就像你建议的一切,然后打电话给uart_clearrxbuffer。可能会有一个更好的方式使用指针或一个更好的时间去做,这也许是我偶尔会想念的来源。 再次感谢 尼克 以上来自于百度翻译 以下为原文 Bob, Thanks a million. That works a lot better. The key was using the GetRxBufferSize as opposed to check RxStatus. I still occasionally miss a character but very rarely and can probably tune that out. My application is a small RS485 network. It seems like the 4 byte buffer is good for a human typing commands from a terminal but I need to be able to do both terminal and automated serial commands and this works well for both. I had a similar issue with the USBUART and it seems like the GetRxBufferSize is a close cousin of the USBUART_GetAll() command. To simplify matters, I get everything with the GetRxBufferSize in the while loop like you suggested, then call UART_ClearRxBuffer. There might be a better way using pointers or a better time to do that and it may be the source of my occasionally miss. Thanks again, Nick |
|
|
|
“CurrBuffReR()”可能是丢失字符的原因,它抛掉存储在缓冲区中的任何信息。从缓冲区中检索字符将其从队列中移除,因此不需要(除了软件重置)使用CurnBuffReor()。
当时间不紧迫时,我再次建议您编写自己的循环缓冲区。不是因为你需要,而是为了理解一个基本术语来解决存储数据的问题,并在以后检索它们。 鲍勃 以上来自于百度翻译 以下为原文 The "ClearBuffer()" might be the cause for missing characters sometimes, it throws away any information still stored in the buffer. Retrieving a character from the buffer removes it from the queue, so there is no need (except for a software resetting) to use ClearBuffer(). When time is not pressing: Again I would suggest you to write your own circular buffer. Not because you need to, but only to understand one of the basic pronciples to solve the problem of storing incoming data and retrieve them later. Bob |
|
|
|
是的,当我有时间的时候,我会立刻试试看。
还有一个问题。你喜欢检索数据的功能?我使用了UARTHETGETCHAR和UARTHAREADRXXDATA,它们似乎都与GeTrxBuffResiZe()循环方法的工作原理相同。 尼克 以上来自于百度翻译 以下为原文 Yes, I'll try that immediately while I actually have the time. One other question. Which function do you prefer to retrieve the data? I have used the UART_GetChar and UART_ReadRxData and they both seem to work about the same with the GetRxBufferSize() loop approach. Nick |
|
|
|
UARTHETGECHARE()包含状态信息,不能用于二进制数据。
uart_readrxdata()假定国家已签(因为它是在你的例子中),而不是getchar()您可能会收到一个二进制0x00。这是我喜欢的方式。 鲍勃 以上来自于百度翻译 以下为原文 UART_GetChar() includes a status info and cannot be used for binary data. UART_ReadRxData() assumes that the state is already checked (as it is the case in your example) and as opposed to GetChar() you may receive a binary 0x00. This is the way I prefer. Bob |
|
|
|
你好,鲍伯, 我试图通过UART将1024字节的数据发送到PSoC 5LP设备。作为一个简单的测试,一旦我收到1024字节,我只是回音验证。我已经为Rx和Tx.设置了FIFO大小为1024,我有一个1024大小的数组,当我接收每个字节时,我把它移到一个本地数组。我使用UARTHAREDRADXDATA()来读取字节。它像我预期的那样工作。 在读取数据表并通过UART .C源代码(自动生成)时,我发现下面的数组,我认为程序是在内部使用的: 易失性UITN8 UARTHARRX缓冲区 我试着从我的主程序中读取这个数组,但是没有成功。我想如果自动生成的源代码已经使用了一个数组,为什么我不能使用它,这样就不需要另一个本地数组了。我还发现UARTHARRXBuff[]是一个全局变量。 这个数组不是用户可访问的吗?或者是我的理解有什么不对吗? 任何帮助都是值得赞赏的。 问候,Sinoj 以上来自于百度翻译 以下为原文 Hello Bob, I am trying to send 1024 bytes of data as a single command via UART to a PSoC 5LP device. As a simple test once I receive 1024 bytes I just echo it back to verify. I have set the FIFO size as 1024 for Rx and Tx. I have an array of 1024 size and as I receive each byte I move it to a local array. I use UART_ReadRxData() for reading the byte. It works as I expected. While reading the datasheet and going through the UART.c source code (automatic generated) I found the following array which I think the program is using internally: volatile uint8 UART_rxBuffer[UART_RX_BUFFER_SIZE] I tried to read this array from my main program but was not successful. I thought if the automatic generated source code is already using an array, why can't I just use that, so that there's no need of another local array. And I also found that the UART_rxBuffer[] is a global variable. Is this array not user accessible or am is there something wrong with my understanding? Any help is appreciated. Regards, Sinoj |
|
|
|
UART内部缓冲区是一个“循环缓冲器”,用于存储输入(和第二个用于传出)数据。因为这个缓冲区随着数据的接收而改变,所以不建议直接访问它。此外,不能保证您的第一个字节存储在缓冲区[0 ],有单独的读写索引。
提示:声明RX和TX缓冲区大于预期的数据。这将防止在从缓冲区读取数据时不够快的情况下重写。 鲍勃 以上来自于百度翻译 以下为原文 The UART internal buffer is a "Circular Buffer" which is used to store incoming (and a second one for outgoing) data. Because this buffer changes with the reception of data it is not recommended to access it directly. Furthermore it is not guaranteed that your first byte is stored at buffer[0], there are separate read and write indices. A tip: Declare the RX and TX buffers larger than the data you are expecting. That will prevent overwriting in the case you are not fast enough reading the data from the buffer. Bob |
|
|
|
只有小组成员才能发言,加入小组>>
754个成员聚集在这个小组
加入小组2103 浏览 1 评论
1849 浏览 1 评论
3667 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1784 浏览 6 评论
1534 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
568浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
422浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
437浏览 2评论
383浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
915浏览 2评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 00:03 , Processed in 1.203861 second(s), Total 96, Slave 80 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号