This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC1352P:UART2_MODE_NONBLOCKING 中200-500us 的 UART2_WRITE ()阻塞

Guru**** 2482225 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1232948/cc1352p-uart2_write-blocking-for-200-500-us-in-uart2_mode_nonblocking

器件型号:CC1352P

您好!  

SDK 6.41.0.17 + syscfg 1.15.0 + CCS 12.3.0.00005  

我正在低优先级 RTOS 任务循环中将数据从无线电移动到 UART。  
我注意到,使用 GPIO 切换和计时范围, UART2_WRITE ()阻止了我的线程200-500 us。

您能告诉我、我是否正确设置了这个吗? 对于非阻塞 API,200-500 us 是正常的吗?

void appUartInit() {
    UART2_Params uartParams;
    UART2_Params_init(&uartParams);
    uartParams.baudRate = 8*115200;
    uartParams.writeMode = UART2_Mode_NONBLOCKING;
    uartParams.readMode = UART2_Mode_NONBLOCKING;
    /*
     * UART2_ReadReturnMode_PARTIAL unblocks or performs a callback whenever a read timeout error occurs on the UART peripheral.
     * This timeout error is not the same as the blocking read timeout in the UART2_Params;
     * the read timeout occurs if the read FIFO is non-empty and no new data has been received for a device/baudrate dependent number of clock cycles.
     * This mode can be used when the exact number of bytes to be read is not known.
     */
    uartParams.readReturnMode = UART2_ReadReturnMode_PARTIAL;

    uart[1] = UART2_open(CONFIG_UART_0, &uartParams);

    if (uart[1] == NULL)
    {
        while (1) {}
    }
}

int appUartWrite(uint8_t *buf, int len) {
    size_t bytesWritten = 0;
    GPIO_write(CONFIG_GPIO_0, 1);
    UART2_write(uart[1], buf, len, (size_t *)&bytesWritten);
    GPIO_write(CONFIG_GPIO_0, 0);
    return bytesWritten;
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Mike:  

    您的设置似乎没有问题。  

    我检查了 SDK 中的 UART2.c 源文件、似乎数据已复制到 UART 环缓冲区、然后开始调用 DMA 传输。 在阻塞模式下、它等待 DMA 完成传输、在非阻塞模式下、它只会返回。 我认为您看到的延时时间是将该数据复制到环形缓冲区中。 因此、延迟取决于传输的字节数。   

    您可以检查从较高优先级运行呼叫是否有帮助。  

    此致、

    SID

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    谢谢 Siddanth。  

    当我浏览代码时、我注意到了同样的情况。 我将传输128字节。  

    我的确注意到、当我没有指定非阻塞模式并将其保留为默认阻塞模式时、它的性能会更好一点。  
    我刚刚使用了 Uart2_params_init ()中的参数,然后只更改了波特率。  

    我添加了一些 GPIO 切换,我注意到我的无线电线程实际上中断了我在 Uart2_write()中的100 us 时间,所以它在该函数中花费了大约200-300 us 的时间,中间有一个100 us 的上下文切换。  

    我发现优先级似乎没有影响在 Uart2_write()中花费的时间,所以我将我的所有任务恢复为相同的优先级,就像我之前注意到这个问题一样。 事情似乎稳定,系统的时间被拨入。  

    在非阻塞模式下、我看到无线电线程延迟、从而导致 TX 实际发生时出现计时抖动。  
    在阻塞模式下,我的无线电线程不会延迟,大概是因为在 Uart2_write()中阻止 UART 任务时,我的 TX 会被调度。