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.

TM4C123GH6PM: Adding Parity to UART1

Part Number: TM4C123GH6PM

I'm having trouble trying to initialize my UART with an odd parity.  I was originally using the following, which configures the UART with no parity:

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);

    ROM_GPIOPinConfigure(GPIO_PB0_U1RX);
    ROM_GPIOPinConfigure(GPIO_PB1_U1TX);
    ROM_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    ROM_IntMasterEnable();

    ROM_UARTClockSourceSet(UART1_BASE, UART_CLOCK_PIOSC);

    ROM_IntEnable(INT_UART1);

    UARTStdioConfig(1, 19200, 16000000);  //baud rate 19200 based on 16mhz crystal

    ROM_UARTIntEnable(UART1_BASE, UART_INT_RX);

I tried replacing the UARTStdioConfig call with

UARTConfigSetExpClk(UART1_BASE, 16000000, 19200, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_ODD);

However, I can no longer establish communication after making this change.  The configuration of the PLC I'm communicating with is also set to 19200 baud, 8 data bits, 1 stop bit, odd parity, etc.

Is there a difference between using the uartstdio and uart functions?  Is there something else I'm missing?

I'm sorry if there's already a question about this topic.  I tried searching the forums first and could not find anyone with the same problem.

Thank you.

  • Hello Justin,

    If you are using other functions from the uartstdio.c file to print your UART data but you don't use UARTStdioConfig, then those functions do not have the configuration information to operate.

    Since UARTStdioConfig does not support changing parity by default, I would recommend changing parity by doing the following:

    1) Call UARTStdioConfig so the right UART Baud Rate, UART Base, etc. are given to uartstdio functions.

    2) Call your UARTConfigSetExpClk immediately after to then set the right parity settings.

  • Hi Ralph,

    That worked perfectly!  Thank you!

    Justin Repperger