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.

CC1312R: Dynamic / Runtime configuration of UART flow control

Part Number: CC1312R
Other Parts Discussed in Thread: SYSCONFIG

Hi!

Is it possible to change the UART flow control (CTS/RTS) during runtime?

From what I can see, the flow control is set using the UARTCC26XX_HWAttrsV2 struct used in the UART_Config struct. These are declared const and does not seem to be meant for modifications after the UART is configured for the first time. Indeed, we get crashes if we try to change them.

However, our use case includes the ability to dynamically enable/disable UART flow control during operation. Is this at all possible?

We've looked into using driverlib functions such as UARTHwFlowControlEnable and IOCPortConfigureSet, but we haven't been able to get it to work.

  • Hei Frode,

    I don't think this is possible, I have assigned someone to look into it.

    Cheers,

    Marie H.

  • Hi Frode,

    Given that we are talking about hardware flow control, the configuration takes place in Sysconfig and it's therefore done so that the hardware attributes of the UART are not changed during runtime (hence the use of const).

    But let me go through the driver code to see if there is a safe way to circumvent these limitations.

    BR,
    AndresM

  • Hi again,

    I think there might be a way of doing this, albeit it involves suppressing some error/warnings from Sysconfig.

    What you can do is to have two UART handles that share the same UART peripheral (i.e. physical pins). One of these handles will have Flow Control enabled, while the other won’t.

    Of course, Sysconfig will trigger a “Resource conflict” error. But here is what you can do to suppress it.

    1. Add first UART handle without Flow Control.
    2. In the PinMux section (Sysconfig) of the UART handle, set the UART peripheral to a fixed value (e.g. UART0)
    3. Add second UART handle with Flow Control. It will default to the second UART peripheral.
    4. In the PinMux section (Sysconfig) of the second UART handle, set the UART peripheral to the same fixed value as before (i.e. UART0). This will trigger the “Resource conflict” error. Click “Ignore”.
    5. In this same section, and still for the second UART handle, assign the Tx and Rx pins to the same pins that you have selected for the first handle. This will again trigger a couple of “Resource conflict” errors. Click on “Ignore” for both of them.
    6. Choose the pins that you want for the Flow Control of the second UART handle.
    7. At this point, you will have some warnings on both UART handles. Click “Suppress” for all of the warnings. The “Warning” symbol will remain, but it will be grey. By doing this, you will avoid any warnings during compile time.

    It should look something like this:

    And the generated code will probably look something like this:

    Now, the most important thing to make this work is that both UART handles cannot be open at the same time. So, you will be basically multiplexing the driver. So your code will look something like this.

    void *mainThread(void *arg0)
    {
        const char  echoPrompt0[] = "This is UART0\r\n";
        const char  echoPrompt1[] = "This is UART1\r\n";
    
        UART_Handle uart0;
        UART_Handle uart1;
    
        UART_Params uartParams;
    
        /* Call driver init functions */
        UART_init();
    
        /* Create a UART with data processing off. */
        UART_Params_init(&uartParams);
        uartParams.writeDataMode = UART_DATA_BINARY;
        uartParams.readDataMode = UART_DATA_BINARY;
        uartParams.readReturnMode = UART_RETURN_FULL;
        uartParams.baudRate = 115200;
    
        uart0 = UART_open(CONFIG_UART_0, &uartParams);
        UART_write(uart0, echoPrompt0, sizeof(echoPrompt0));
        UART_close(uart0);
    
        uart1 = UART_open(CONFIG_UART_1, &uartParams);
        UART_write(uart1, echoPrompt1, sizeof(echoPrompt1));
        UART_close(uart1);
    }

    BR,
    AndresM