EdwardLee 发表于 2021-7-13 18:56:58

QCC512x UART偶尔会收不到数据,该如何配置使用?

不同板子的出现的概率不一样,有些挺高的,有些则很低。但对方发送的数据又不在缓冲区,应该是丢数据。

测量波形,没有异常,纯粹是、5120这边收不到而已。

代码如下:



void uartInit(void)
{
    uint8 i;
    UART_PIO uart_pios[] = {{PIO_UART_RX, UART_RX},
                            {PIO_UART_TX, UART_TX}};

    for (i = 0; i < ARRAY_DIM(uart_pios); i++)
    {
      uint16 pio = uart_pios.pio;
      uint16 bank = PBANK(pio);
      uint32 mask = POFFM(pio);

      /* Setup uart PIOs with strong pull-up */
      PanicNotZero(PioSetMapPins32Bank(bank, mask, 0));
      PanicFalse(PioSetFunction(pio, uart_pios.func));
      PanicNotZero(PioSetDir32Bank(bank, mask, 0));
      PanicNotZero(PioSet32Bank(bank, mask, mask));
      PanicNotZero(PioSetStrongBias32Bank(bank, mask, mask));
    }

    /* Assign task message handler */
    theUARTStreamTask.task.handler = uartMessageHandler;

    /* Get the sink for the uart */
    theUARTStreamTask.uart_sink = StreamUartSink();
    if(theUARTStreamTask.uart_sink != 0)
    {
      PanicNull(theUARTStreamTask.uart_sink);
    }

    /* Get the source for the uart */
    theUARTStreamTask.uart_source = StreamUartSource();
    if(theUARTStreamTask.uart_source != 0)
    {
      PanicNull(theUARTStreamTask.uart_source);
    }

    StreamConfigure(VM_STREAM_UART_CONFIG, VM_STREAM_UART_THROUGHPUT);

    StreamConfigure(VM_STREAM_UART_SLEEP_TIMEOUT, 0);

    /* Configure uart settings */
    StreamUartConfigure(VM_UART_RATE_9K6, VM_UART_STOP_ONE, VM_UART_PARITY_NONE);

    /* Register uart source with task */
    MessageStreamTaskFromSink(StreamSinkFromSource(theUARTStreamTask.uart_source), &theUARTStreamTask.task);
}
void uartRxdata(Source src)
{
    uint8 i;
    uint16 length = 0;
    const uint8 *data = NULL;

    /* Get the number of bytes in the specified source before the next packet boundary */
    if(!(length = SourceBoundary(src)))
    {
      return;
    }
   
    /* Maps the specified source into the address map */
    data = SourceMap(src);
    PanicNull((void*)data);

    /* Transmit the received data */
    /*uart_data_stream_tx_data(data, length);*/

    UART_DEBUG(("UART: Rx: length %d", length));
    for(i = 0; i < length; i++)
    {
      UART_DEBUG((" data[%d] [%x]", i, data));
    }
    UART_DEBUG(("\n"));

    /* Discards the specified amount of bytes from the front of the specified source */
    SourceDrop(src, length);
}
void uartMessageHandler (Task pTask, MessageId pId, Message pMessage)
{
    UNUSED((pTask));

    switch (pId)
    {
      case MESSAGE_MORE_DATA:
      {
            uartRxdata(((MessageMoreData *)pMessage)->source);
      }
      break;

      default:
      break;
    }
}

bluetooth 发表于 2021-7-14 08:17:00

关闭休眠试试,867x也有这个问题的。

EdwardLee 发表于 2021-7-14 09:28:21

bluetooth 发表于 2021-7-14 08:17
关闭休眠试试,867x也有这个问题的。

是dormant?还是 deep sleep?

522315697 发表于 2021-7-14 10:04:35

EdwardLee 发表于 2021-7-14 09:28
是dormant?还是 deep sleep?

http://www.52bluetooth.com/portal.php?mod=view&aid=123

EdwardLee 发表于 2021-7-14 10:27:20

骑着蟑螂去上学 发表于 2021-7-14 10:04
http://www.52bluetooth.com/portal.php?mod=view&aid=123

解决了。

CuratorDeepSleepConfig = 0x0000

瞬间 发表于 2021-7-22 19:28:03

EdwardLee 发表于 2021-7-14 10:27
解决了。

CuratorDeepSleepConfig = 0x0000

功耗有增加吗?

EdwardLee 发表于 2021-7-23 18:33:22

瞬间 发表于 2021-7-22 19:28
功耗有增加吗?

相对整体功耗,可以忽略不记吧。

李小千 发表于 2021-7-28 10:15:46

关于明天的事,我们后天就知道了。:D

保羅071977 发表于 2022-1-3 16:44:12

有 Tx的 write code嗎?

EdwardLee 发表于 2022-3-22 19:55:10

保羅071977 发表于 2022-1-3 16:44
有 Tx的 write code嗎?

把睡眠关了就可以了。
页: [1]
查看完整版本: QCC512x UART偶尔会收不到数据,该如何配置使用?