CC3551E: UART driver write issue

Part Number: CC3551E

    I observed an abnormal phenomenon while testing continuous serial port transmission. After sending a few packets of data (each packet being 256 bytes during the test), there is an interval of approximately 7.5ms in the middle of one packet. This causes the transmission speed to slow down. I tried both UART2_Mode_BLOCKING and UART2_Mode_CALLBACK in writeMode, and the same phenomenon occurs. The testing method is as follows:

1. The serial port configuration is as follows:

  • UART2_Params params;
  • UART2_Params_init(&params);
  • params.baudRate = 921600;
  • params.writeMode = UART2_Mode_BLOCKING;
  • params.readMode      = UART2_Mode_CALLBACK;
  • params.readCallback  = readCallback;
  • params.readReturnMode = UART2_ReadReturnMode_PARTIAL;
  • theHUART.handle = UART2_open(CONFIG_UART2_1, &params);

2. Send via the following method: Create a transmission task with each packet of 256 bytes. In this task, send continuously. Configure a GPIO pin to pull high before each transmission and pull low after completion, which facilitates convenient observation of this anomaly.

  • static int host_control_uart_send(const uint8 *buffer, uint16 length)
  • {
  •     size_t bytesWritten;
  •     SET_SEND_GPIO_HIGH;
  •     int_fast16_t status = UART2_write(theHUART.handle, buffer, length, &bytesWritten);
  •     if (status != UART2_STATUS_SUCCESS) {
  •         return 0;
  •     }
  •     SET_SEND_GPIO_LOW;
  •     return bytesWritten;
  • }
  • void uart_test_thread(void* arg )
  • {
  •     uint8_t test_buf[256];
  •     for(int i=0; i<256; i++)
  •     {
  •         test_buf[i] = i;
  •     }
  •     while(1)
  •     {  
  •         host_control_uart_send(test_buf, 256);
  •         vTaskDelay(1/portTICK_PERIOD_MS);
  •     }
  •     vTaskDelete(NULL);
  • }
  •  
  • void host_uart_test(void)
  • {
  •     xTaskCreate(uart_test_thread, ((const char*)"uart_test_thread"), 1024, NULL, tskIDLE_PRIORITY + 3, NULL);
  • }

3. The phenomenon captured by the logic analyzer is as follows: after sending a few packets of data, there is an interval of approximately 7.5ms in the middle of one packet transmission, which will result in a slower speed when sending data continuously.

image.png

image.png

  • Hi zhong wei,

    Thanks for the feedback on our UART driver. I will look into this and get back to you shortly this week.

  • Hello zhong wei,

    I didn't realize my message never sent out. Sorry to keep you waiting.

    I wanted to tell you that I did not follow your steps (since you were experimenting there anyway), and ultimately did not recreate your issue.

    I have attached my code and SYSCFG to this response.

    When hooking up the logic analyzer, I never saw a 7.5 ms delay, which you can see since my entire 256 byte transaction took place within the green block:

    I had 4 transactions (1 second delay in between) and none had any delay in the middle of a packet.

    I am open to your feedback.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/968/uart2echo.syscfg

    /*
     * Copyright (c) 2020-2025, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== uart2echo.c ========
     */
    #include <stdint.h>
    #include <stddef.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/UART2.h>
    
    /* Driver configuration */
    #include "ti_drivers_config.h"
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        char input[] = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
        const char echoPrompt[] = "Echoing characters:\r\n";
        UART2_Handle uart;
        UART2_Params uartParams;
        size_t bytesRead;
        size_t bytesWritten = 0;
        int_fast16_t status = UART2_STATUS_SUCCESS;
    
        /* Call driver init functions */
        GPIO_init();
    
        /* Configure the LED pin */
        GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Create a UART where the default read and write mode is BLOCKING */
        UART2_Params_init(&uartParams);
        uartParams.baudRate = 921600;
    
        uart = UART2_open(CONFIG_UART2_0, &uartParams);
    
        if (uart == NULL)
        {
            /* UART2_open() failed */
            while (1) {}
        }
    
        /* Turn on user LED to indicate successful initialization */
        GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
    
        UART2_write(uart, echoPrompt, sizeof(echoPrompt), &bytesWritten);
    
        /* Loop forever echoing */
        while (1)
        {
            // bytesRead = 0;
            // while (bytesRead == 0)
            // {
            //     status = UART2_read(uart, &input, 1, &bytesRead);
    
            //     if (status != UART2_STATUS_SUCCESS)
            //     {
            //         /* UART2_read() failed */
            //         while (1) {}
            //     }
            // }
    
            // bytesWritten = 0;
            // while (bytesWritten == 0)
            // {
                status = UART2_write(uart, &input, 256, &bytesWritten);
    
                if (status != UART2_STATUS_SUCCESS)
                {
                    /* UART2_write() failed */
                    while (1) {}
                }
    
                sleep(1);
            // }
        }
    }

  • Hi Bliu:

        I have re-investigated and found the root cause. I enabled hardware flow control for the serial port and connected a Dupont line to UART0_CTS (GPIO19) for testing. When this line is left floating, the 7.5ms interval can be stably reproduced in an office environment, but this phenomenon does not occur in another environment. After removing this Dupont line, the 7.5ms interval no longer appears regardless of the environment. Now I am not sure why this issue happens.

  • Hi zhong wei,

    Thanks for letting me know. My setup did not use CTS so let me take another look. Your setup that results in no interval is probably similar to what I have.

  • Hi zhong wei,

    I am struggling to reproduce your issue. I enabled flow control in SYSCFG and still did not see your issue; I did not hook anthing up to the flow control pins either. Please see my analyzer trace:

    Each block looked like this which showed 0 indication of a 7.5 ms delay.

    You can see I'm just probing my device which is running a uart2echo example (code I sent you previously). Can you try that setup and then adapt it your application?