完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
我正在运行低级UART W/ISR的示例应用CE219656。该部分已更改为运行在PSoC6 WiFi板上。未修改的代码工作正常。然而,对于我的应用程序,我想看看在执行FIFO读之前,RX FIFO堆栈上最新接收到的字节是什么(即我想在FIFO弹出之前偷窥)。这应该是通过读取RXYFIFOZRDY静默寄存器而不是中断服务例程中的RXI FIFORYRD寄存器来实现的。但是,当我将这行添加到ISR代码:Read StaseDe= UARTHYHW-GT;RXYFIFORZRDY静默在调用Read Opthys= CysScBuUARTHEGET(UARTHYHW)之前,数据被损坏;即不正确的字符被写入终端。我猜想,添加Read Office=UARTHYHW-GT;RXA FIFOORDDSIOLL不应该破坏代码。我能正确地理解这一点吗?谢谢你,史葛 以上来自于百度翻译 以下为原文
|
|
相关推荐
3个回答
|
|
我只是回顾了这段代码,注意到在中断代码中有一个bug。您的用例导致这个bug出现。
错误是在FIFO中读取数据之前清除RX FIFO非空中断。在代码示例中,在中断被清除之后,FIFO被直接读取,我相信它足够快,不会导致中断重新触发。在您的情况下,在中断清除和实际读取之间插入代码,这会导致中断再次触发。因此,ISR再次进入,导致它从空FIFO中读出… 为了解决这个问题,在FIFO的读取下移动中断清除代码: Read数据=UARTHYHW-gt; *从终端获取字符* RealthDATA=CysScBuUARTHEGET(UARTHYHW); /*清除UART“RX FIFO不空中断”*/ UARTHY-HW-GT;InTyrx=UARTHY-HW-GT; 但是,对于这个代码,仍然存在一个问题,它引起了中断,因为一个不同的原因,我还没有调试过。因此,对于您的用例充分工作,你需要改变你的ISR看起来像: 空隙ISRUUART(无效) { *检查“RX FIFO不是空中断”*/ 如果(UARTHI HW-GT;InthRx掩码和SCBIInrxRxMaskddNoToPosiTyjyMSK)!= 0) { Read数据=UARTHYHW-gt; *从终端获取字符* RealthDATA=CysScBuUARTHEGET(UARTHYHW); /*清除UART“RX FIFO不空中断”*/ UARTHY-HW-GT;InTyrx=UARTHY-HW-GT; /*更新DATAY接收标志*/ DATAY接收=1; } 其他的 { /*如果发生任何其他中断* * //UARTHARE错误=1; } } 当我考虑中断是如何导致错误代码运行时,我会回过头来。我猜是下溢。 以上来自于百度翻译 以下为原文 I was just reviewing this code and noticed that there is a bug in the interrupt code. Your use case caused this bug to show up. The bug is that the RX fifo not empty interrupt is cleared before data is read out of the FIFO. In the code example the FIFO was read directly after the interrupt was cleared which I believe was fast enough to not cause the interrupt to retrigger. In your case you inserted code between the interrupt clear and the actual read, which causes the interrupt to fire again. So the ISR gets entered again which causes it to read out of an empty fifo... To fix the issue move the interrupt clear code below the read of the FIFO: read_data = UART_HW->RX_FIFO_RD_SILENT; /* Get the character from terminal */ read_data = Cy_SCB_UART_Get(UART_HW); /* Clear UART "RX fifo not empty interrupt" */ UART_HW->INTR_RX = UART_HW->INTR_RX & SCB_INTR_RX_NOT_EMPTY_Msk; However with this code there is still an issue which causes the interrupt to fire for a different reason I haven't debugged yet. So for your use case to fully work you need to change your ISR to look like: void ISR_UART(void) { /* Check for "RX fifo not empty interrupt" */ if((UART_HW->INTR_RX_MASKED & SCB_INTR_RX_MASKED_NOT_EMPTY_Msk ) != 0) { read_data = UART_HW->RX_FIFO_RD_SILENT; /* Get the character from terminal */ read_data = Cy_SCB_UART_Get(UART_HW); /* Clear UART "RX fifo not empty interrupt" */ UART_HW->INTR_RX = UART_HW->INTR_RX & SCB_INTR_RX_NOT_EMPTY_Msk; /* Update data_received flag */ data_received = 1; } else { /* Error if any other interrupt occurs */ //uart_error = 1; } } I'll post back when I figure how which interrupt is causing the error code to run. My guess is that it is underflow. |
|
|
|
60user133 发表于 2018-9-29 13:28 你还需要清除ISR中的NVIC。由于FIFO不是空信号是电平,并且NVIC再次触发。 下面是我的代码: 空隙ISRUUART(无效) { *检查“RX FIFO不是空中断”*/ 如果(UARTHI HW-GT;InthRx掩码和SCBIInrxRxMaskddNoToPosiTyjyMSK)!= 0) { Read数据=UARTHYHW-gt; *从终端获取字符* RealthDATA=CysScBuUARTHEGET(UARTHYHW); /*清除UART“RX FIFO不空中断”*/ UARTHY-HW-GT;InTyrx=UARTHY-HW-GT; NVICI- CultBuangIrrq(UARTHI SCBIIQLYCFG.In SRSRC); /*更新DATAY接收标志*/ DATAY接收=1; } 其他的 { /*如果发生任何其他中断* * UARTHARE错误=1; } } 以上来自于百度翻译 以下为原文 You also need to clear the NVIC in the ISR. As the FIFO not empty signal is level, and the NVIC gets triggered again. Here is the code that works for me: void ISR_UART(void) { /* Check for "RX fifo not empty interrupt" */ if((UART_HW->INTR_RX_MASKED & SCB_INTR_RX_MASKED_NOT_EMPTY_Msk ) != 0) { read_data = UART_HW->RX_FIFO_RD_SILENT; /* Get the character from terminal */ read_data = Cy_SCB_UART_Get(UART_HW); /* Clear UART "RX fifo not empty interrupt" */ UART_HW->INTR_RX = UART_HW->INTR_RX & SCB_INTR_RX_NOT_EMPTY_Msk; NVIC_ClearPendingIRQ(UART_SCB_IRQ_cfg.intrSrc); /* Update data_received flag */ data_received = 1; } else { /* Error if any other interrupt occurs */ uart_error = 1; } } |
|
|
|
感谢您的快速和详细的响应! 这确实是意料之中的事情。 最好的问候, 斯科特 以上来自于百度翻译 以下为原文 Thank you for your fast and detailed response! This is indeed working as expected. Best regards, Scott |
|
|
|
只有小组成员才能发言,加入小组>>
754个成员聚集在这个小组
加入小组2098 浏览 1 评论
1845 浏览 1 评论
3664 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1782 浏览 6 评论
1532 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
556浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
409浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
433浏览 2评论
379浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
905浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-18 10:12 , Processed in 1.160522 second(s), Total 83, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号