完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,大家好,
我正在使用UART发送AT命令。 例子如下: UARTHEB DEBUTARTPUT字符串(“AT+UHTTP=0 rn”); 有时它工作,但有时它被困在一个函数中,它永远不会出来。 困在下面而循环: { /*等待,直到TXFIFO有空间放置数据元素*/ 而(UARTHED DeBuffSPixUARTARFIFOZYSIZE==UARTHEA DEBJETGETA TXX FIFOX条目) { } UARTHEDBEXTXXFIFOXWRYRG = TXDATA; } 有人面临类似的问题吗?请建议。 谢谢。 以上来自于百度翻译 以下为原文 Hi All, I am using UART for sending at commands. example as below:- UART_DEB_UartPutString("AT+UHTTP=0rn"); sometimes its working but sometimes its getting stuck in a function UART_DEB_SpiUartWriteTxData and never comes out of it stuck in below while loop:- { /* Wait until TX FIFO has space to put data element */ while (UART_DEB_SPI_UART_FIFO_SIZE == UART_DEB_GET_TX_FIFO_ENTRIES) { } UART_DEB_TX_FIFO_WR_REG = txData; } Did anyone faced similar issue?please suggest. Thanks. |
|
相关推荐
10个回答
|
|
当TX FIFO缓冲区满了,TX无法发送任何字符时,就会发生这种情况。我假设有三个可能的原因。
1)CTS输入被否定。 如果使用CTS输入和输入被否定,则TX无法发送任何字符。 2)禁用UART。 如果UART意外禁用,SPIUARTWRITETXDATA()可以接受字符,但不发送字符。 3)禁用UART时钟。 如果UART时钟内部或外部被禁用,则不发送字符。 如果可能的话,请附上UART的配置对话框快照。 当做, 诺里基 以上来自于百度翻译 以下为原文 This happens when the TX FIFO buffer is FULL and the TX cannot send any character. I assumes three possible reasons. 1) CTS input is negated. If you uses the CTS input and the input is negated, the TX cannot send any character. 2) UART is disabled. If UART is accidentally disabled, SpiUartWriteTxData() can accept characters but no characters are sent. 3) UART clock is disabled. If the UART clock internal or external is disabled, no characters are sent. If possible, please attach a snapshot of the UART's configuration dialogue. Regards, Noriaki |
|
|
|
numuwewr 发表于 2018-12-20 13:38 嗨,Noriaki, 谢谢你的回复。 PFA为UART的PSoC创建者配置。 当做, 萨加尔 UARTHEXCONTION3.PNG 23.8 K UARTHONGROUTION2.PNG 24.4 K UARTHOTICONTIL1.PNG 18.9 K 以上来自于百度翻译 以下为原文 Hi Noriaki, Thanks for the reply. PFA the PSOC Creator Configuration for UART. Regards, sagar
|
|
|
|
你能附上你的项目吗? 谢谢, 希马 以上来自于百度翻译 以下为原文 Can you attach your project? Thanks, Hima |
|
|
|
我的项目遇到了同样的问题。实际上,在“SPI模式”下,用SCB外围设备与SPI设备进行对话。附件是我的配置。完全相同的功能:它几乎总是工作,似乎有一个问题时,我增加了数据量的总线/互动与SPI输入设备。锁定在与SaGARD相同的线路,等待在TXFIFO中打开。
谢谢, 尼克 以上来自于百度翻译 以下为原文 I'm having the same problem in my project. Actually talking to a spi device with an SCB peripheral in "spi mode". Attached are my configurations. Exact same functionality: it almost always works, seems to have a problem when I increase the amount of data on the bus/interact with the SPI input device. Locks up at the same line as sagard waiting for an opening in the tx fifo. Thanks, Nick |
|
|
|
60user170 发表于 2018-12-20 14:27 我用下面的源代码确认了这个问题。 包括“项目H” UTIN TXDATA〔16〕={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; 主(空) { CyGloalActuabess;/*启用全局中断。*/ *将初始化/启动代码放在此处(例如MyStimSistAd())*/ SPIMARSTATE(); SpimthSPIUARTPART阵列(TXDATA,SIXOF TXDATA); (;) { *将您的应用程序代码放在这里。*/ CyTeles(1000); } } 在这个程序中,16字节的数据将通过SPI主机发送。数据是由方法SpuuARTPARRAY()写入的。 执行被困在下面的行中。 结果发现,当发送第十字节“10”时,程序停止。第一字节已经发送给从机。第二到第九字节(总共八字节)存储在TXFIFO中。但是FIFO中的这些字节没有发送到SPI。我不知道FIFO不消耗的原因。 当TX缓冲区大小大于8时,使用中断请求驱动的软件FIFO,所有数据都被SPI接受。 这能解决问题吗? 当做, 诺里基 P4MYSPI.Cyrj.CaseVo.01.Zip 519.8 K 以上来自于百度翻译 以下为原文 I have confirmed the issue with following source code. #include "project.h"uint8 txData[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};int main(void){ CyGlobalIntEnable; /* Enable global interrupts. */ /* Place your initialization/startup code here (e.g. MyInst_Start()) */ SPIM_Start(); SPIM_SpiUartPutArray(txData, sizeof txData); for(;;) { /* Place your application code here. */ CyDelay(1000); }} In this program, 16 bytes of data is going to be sent via SPI master. The data is written by the method _SpiUartPutArray() at once. The execution is stuck at following line. It was found that the program stops when the 10th byte "10" is to be sent. The 1st byte is already sent to the slave. The 2nd to 9th bytes (total eight bytes) are stored in the TX FIFO. But these bytes in the FIFO are not sent to SPI. I don't know the reason why FIFO does not consumed. When the TX buffer size is larger than 8 to use the software FIFO driven by the interrupt requests, all data is accepted by the SPI. Could this be a workaround? Regards, Noriaki
|
|
|
|
numuwewr 发表于 2018-12-20 14:46 如果没有中断,可以从FIFO传输字节,那么它就不会消耗字节。 如果你没有时钟的SPIM滴答,那么它也不会时钟的TX字节从FIFO。 如果您在等待TX字节发出时处于中断状态,这可能是问题的起因。 以上来自于百度翻译 以下为原文 If you don't have interrupts enabled to transmit the bytes from FIFO, then it will not be consuming the bytes. If you don't have the clock for the SPIM ticking, then it also won't be clocking the TX bytes out of the FIFO. If you are current IN an interrupt while waiting for the TX bytes to send out, that could be the cause of the issue. |
|
|
|
60user170 发表于 2018-12-20 14:27 嗨,Nick, 我认为没有中断启用是你问题的根源。您也可以直接写入发送硬件寄存器,如: 因此,写入的第一个字节(0x01)开始移出PIN,并且其他值的后续写入TxDATA只是丢失。他们没有得到缓冲。你需要启用一个内部中断,它有一个服务程序从缓冲区收集字节,并在每个发送完成后将它们写入到写寄存器中。 看下面的答案(以下问题),以使这一点更清楚。 以上来自于百度翻译 以下为原文 Hi Nick, I think that not having interrupts enabled is the source of your problem. You are also writing directly to the transmit hardware register like so: So the first byte written (0x01) starts shifting out of the pin and subsequent writes of the other values to txData are just lost. They aren't getting buffered. You need to enable an internal interrupt and that has a service routine that gathers bytes from a buffer and writes them into the write register after each one is done transmitting. See subsequent answers (on following questions) to make this more clear. |
|
|
|
numuwewr 发表于 2018-12-20 14:46 只有在没有软件TX缓冲区的情况下,才建立在线309上的代码: SpimaCuffixTxSWSWAL缓冲区 但我看到了另外一些东西。此宏使用掩码: 定义了SPIMGETGETTXXFIFOX条目(SPIMUTXXFIFOSATSTUSSYRG和AMP); SpimtxxFIFO-StasuSuSudid掩码 下面是口罩的定义。 *定义SPIMURXXFIFOSSTATUSSUSEDY掩码((UTIT32)SPIMIFFFDATA.NRRLog2PPLUS 1掩码) 下面是状态寄存器使用的位的描述: /*SPIMUTXXFIFOXSTATUSSYRG** *定义TxFixtFasoStasuSuthSuxEdEdPOS(0U)/*[3:0]在TXFIFO *中的条目数量 所以你可能会认为面具是0x0F。 它不是: *定义FIFO中的SPIMARFFYDATA、NRR2Log2PLU11掩码(0x1FU)/*位来表示字节。*/ 我们可能还有另外一个问题,4位产生了一个坏结果吗? 以上来自于百度翻译 以下为原文 That code on line 309 is only built if you do not have a software TX buffer enabled: SPIM_CHECK_TX_SW_BUFFER But I'm seeing something else. This macro uses a mask: #define SPIM_GET_TX_FIFO_ENTRIES (SPIM_TX_FIFO_STATUS_REG & SPIM_TX_FIFO_STATUS_USED_MASK) Here's the definition of the mask. #define SPIM_RX_FIFO_STATUS_USED_MASK ((uint32) SPIM_FF_DATA_NR_LOG2_PLUS1_MASK) Here's a description of the bits used by the status reg: /* SPIM_TX_FIFO_STATUS_REG */ #define SPIM_TX_FIFO_STATUS_USED_POS (0u) /* [3:0] Amount of entries in TX FIFO */ So you might think the mask is going to be 0x0F. It isnt: #define SPIM_FF_DATA_NR_LOG2_PLUS1_MASK (0x1Fu) /* Number of bits to represent #bytes in FIFO. */ Possibly we have another problem here with bit 4 generating a bad result? |
|
|
|
nmmmma 发表于 2018-12-20 15:25 宏听起来像是FIFO缓冲字节大小的二进制计数。拥有大量的“计数”不应该是IMO问题的原因。 尽管如此,还是很好地挖掘了差异。 以上来自于百度翻译 以下为原文 That macro sounds like it is a binary count of the FIFO buffer byte size. Having a large available "count" shouldn't be the cause of the issue imo. Nice work digging into the discrepancy though. |
|
|
|
nmmmma 发表于 2018-12-20 15:14 我使用的SPI写函数是: UIT8空[]= {0,0,0}; SPISPISPUARTEPART阵列(空,3); 但是,我使用软件缓冲区将缓冲区大小设置为80。我还轮询FIFO缓冲区而不是使用中断,但我不记得是因为中断对我不起作用,如果我没有能力使用我的设置中断,或者如果我只是懒惰的话。 以上来自于百度翻译 以下为原文 The SPI write function I use is this: uint8 empty[] = {0,0,0}; SPI_SpiUartPutArray(empty,3); However, I have the buffer sizes set to 80 using a software buffer. I am also polling the FIFO buffer instead of using the interrupt, but I don't remember if it was due to the interrupts not working for me, if I had no ability to use the interrupts with my setup, or if I was just lazy |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2069 浏览 1 评论
1826 浏览 1 评论
3639 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1760 浏览 6 评论
1510 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
507浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
357浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
410浏览 2评论
357浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
854浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 16:58 , Processed in 1.058891 second(s), Total 95, Slave 78 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号