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.

CCS/TM4C129ENCPDT: TIVA UART libary does not support FLOW Control

Part Number: TM4C129ENCPDT

Tool/software: Code Composer Studio

I have used the TIVA library to setup and use a non-flow control UART successfully.  However I need to support DCE RTS/CTS control - how do you do this?

I want to use hardware flow-control. I have set the flow control bits in the hardware register -see the code below on the last lines.

How do you assign the pins to the UART RTS and CTS pins to the uart hardware so that these pins are automatically set in hardware?

    // Create UART 1 parameters from the configuration parameters
    UART_Params_init(&uartParams1);
    uartParams1.writeDataMode = UART_DATA_BINARY;
    uartParams1.readDataMode = UART_DATA_BINARY;
    uartParams1.readReturnMode = UART_RETURN_FULL;
    uartParams1.readTimeout = 1;
    uartParams1.writeTimeout = 1;
    uartParams1.readEcho = UART_ECHO_OFF;
    uartParams1.baudRate = WorkingConfigParams.rs232_param[1].baud;
    uartParams1.parityType = WorkingConfigParams.rs232_param[1].parity;
    uartParams1.stopBits = WorkingConfigParams.rs232_param[1].stop;
    uartParams1.readMode = UART_MODE_BLOCKING;

    // sanity check the baud rate
    if (uartParams1.baudRate < 300)
        uartParams1.baudRate = 9600;

    // open the UART1 device
    Rs232Uart1 = UART_open(Board_UART1, &uartParams1);

    if (Rs232Uart1 == NULL)
    {
       System_printf("Error Opening UART 1...%d\n",errno);
    }
    else
    {
        // cancel any pending read or write
        UART_readCancel(Rs232Uart1);
        UART_writeCancel(Rs232Uart1);
    }

// set the ISOLATORS to terminal mode to DCE

SetRJ45Bot_DCE();

// set the flow control
UARTFlowControlSet(UART1_BASE, 0);
if (WorkingConfigParams.rs232_param[1].flowControl)
{
UARTFlowControlSet(UART1_BASE, UART_FLOWCONTROL_TX | UART_FLOWCONTROL_RX);
}

  • You can use the TivaWare library functions to configure the flow control pins. First you need to decide which pins you will use. The TM4C129ENCPDT device has pin multiplexing which gives you a choice of two pins for each of CTS(104-PP3, 108-PN1) and RTS (15-PE0, 107-PN0). Assume we use PN0 and PN1. Also assume this code is after the call to Board_initGeneral() which enables all of the GPIO ports. 

    // set the flow control
    UARTFlowControlSet(UART1_BASE, 0);
    if (WorkingConfigParams.rs232_param[1].flowControl)
    {
        // Set GPIO N0 and N1 as RTS/CTS UART pins.
        GPIOPinConfigure(GPIO_PN0_U1RTS);
        GPIOPinConfigure(GPIO_PN1_U1CTS);
        GPIOPinTypeUART(GPIO_PORTN_BASE, GPIO_PIN_0 | GPIO_PIN_1);
        UARTFlowControlSet(UART1_BASE, UART_FLOWCONTROL_TX | UART_FLOWCONTROL_RX);
    }
    

  • I have also setup the other pins as follows:

        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
        GPIOPinConfigure(GPIO_PB0_U1RX);
        GPIOPinConfigure(GPIO_PB1_U1TX);
        GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
        GPIOPinConfigure(GPIO_PN1_U1CTS);
        GPIOPinConfigure(GPIO_PN5_U1RI);
        GPIOPinTypeUART(GPIO_PORTN_BASE, GPIO_PIN_1 | GPIO_PIN_5);
        GPIOPinConfigure(GPIO_PE3_U1DTR);
        GPIOPinConfigure(GPIO_PE2_U1DCD);
        GPIOPinConfigure(GPIO_PE1_U1DSR);
        GPIOPinConfigure(GPIO_PE0_U1RTS);
        GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

    So to be clear, once I set the UARTFlowControlSet(UART1_BASE, UART_FLOWCONTROL_TX | UART_FLOWCONTROL_RX)

    these other pins will also be controlled?

    However, I do not understand how you set DCE or DTE mode?

    Is UART_FLOWCONTROL_RX - DCE mode and UART_FLOWCONTROL_TX - DTE mode?

  • No, hardware flow control is only CTS and RTS. The other modem control signals must be software controlled, usually in the interrupt routine. See section 19.3.6 of the datasheet.