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: UART send noise , what is the best buad rate setting for my UART

Part Number: TM4C123GH6PM

Hello Guys,

Good day.

Our customer reported that his uart sample program send noise information instead of characters to putty even if he unified baud rate setting in tiva c and pc like in this code:

SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ |SYSCTL_USE_PLL );//for clock

UART0->UARTIBRD  = 104;  /* 16MHz/16=1MHz, 1MHz/104=9600 baud rate */
UART0->UARTFBRD  = 11;   /* fraction part, see Example 4-4 */

the complete code

int main(void)
{
//  SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ |SYSCTL_USE_PLL );
    RCGCUART |=(1<<UART_0);
    ENABLE_GPIO_CLOCK( PORTA );
    /* UART0 initialization */
    UART0->UARTCTL = 0X0; /* disable UART0 */
    UART0->UARTIBRD  = 104;  /* 16MHz/16=1MHz, 1MHz/104=9600 baud rate */
    UART0->UARTFBRD  = 11;   /* fraction part, see Example 4-4 */
    UART0->UARTCC =  0;      /* use system clock */
    UART0->UARTLCRH =  0x60; /* 8-bit, no parity, 1-stop bit, no FIFO */
    UART0->UARTCTL = 0x301; /* enable UART0, TXE, RXE */

    /* UART0 TX0 and RX0 use PA0 and PA1. Set them up. */
    GPIODEN_APB_PORTA   |= 0X3 ; //U0Rx  , U0Tx

    GPIOAFSEL_APB_PORTA |= 0X3 ; //U0Rx  , U0Tx

    GPIOPCTL_APB_PORTA  |= 0X11 ; //U0Rx  , U0Tx
    TRANSMITE_UART_CHAR(UART_0 ,'y');
            TRANSMITE_UART_CHAR(UART_0 ,'e');
            TRANSMITE_UART_CHAR(UART_0 ,'s');
            TRANSMITE_UART_CHAR(UART_0 ,'\n');
            TRANSMITE_UART_CHAR(UART_0 ,'\r');
    while(1)
    {
//        TRANSMITE_UART_CHAR(UART_0 ,'y');
//        TRANSMITE_UART_CHAR(UART_0 ,'e');
//        TRANSMITE_UART_CHAR(UART_0 ,'s');
//        TRANSMITE_UART_CHAR(UART_0 ,'\n');
//        TRANSMITE_UART_CHAR(UART_0 ,'\r');
    }
}

What could be the problem ?

Thanks and regards,

Art

  • Hello Art,

    Why is the customer not using TivaWare API's to handle UART configuration and transmission?

    We do not provide support for direct register programming for TM4C as TivaWare APIs handle this sort of configuration quickly and simply. I don't see a need for them to use DRM code for this application. I would suggest they use uart_echo as a basis.

    Best Regards,

    Ralph Jacobi

  • Hello Ralph,

    Below are the response from the customer:

    "The whole code Work fine but it send noise may be baud rate issue, So i try by tivaware to put different Inputs to CRYSTAL configuration code.

    SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ |SYSCTL_USE_PLL );//for clock

    So could you help me. what is the best option for this code to fix the program?"

    Thanks and regards,

    Art

  • Hello Art,

    PLL configuration for 80 MHz is:

        //
        // Set the system clock to run from the PLL at 80MHz.
        //
        MAP_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_INT |
                           SYSCTL_XTAL_16MHZ);

    Best Regards,

    Ralph Jacobi

  • Hello Ralph,

    The code does not work according to the customer. He sent a bunch of codes which he hope you could review.

    //this is the main of my code
    #include<stdio.h>
    #include <stdint.h>
    #include <stdbool.h>
    #include "hw_memmap.h"
    #include "hw_types.h"
    #include "sysctl.h"
    #include"types.h"
    #include"SYSCRL_private.h"
    #include"SYSCRL_config.h"
    #include"SYSCRL_interface.h"
    #include"bitwise.h"
    #include"DIO_private.h"
    #include"DIO_config.h"
    #include"DIO_interface.h"
    #include"SYSTIC_config.h"
    #include"SYSTIC_interface.h"
    #include"SYSTIC_pravite.h"
    #include"ADC_private.h"
    #include"ADC_interface.h"
    #include"ADC_config.h"
    #include"UART_pravite.h"
    #include"UART_interface.h"
    #include"UART_conf.h"


    /**
    * main.c
    */
    int main(void)
    {

    //SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ |SYSCTL_USE_PLL );

    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_INT |
    SYSCTL_XTAL_16_3MHZ);

    RCGCUART |=(1<<UART_0);
    ENABLE_GPIO_CLOCK( PORTA );
    /* UART0 initialization */
    UART0->UARTCTL = 0X0; /* disable UART0 */
    UART0->UARTIBRD = 104; /* 16MHz/16=1MHz,

    UART0->UARTFBRD = 11; /* fraction part, see Example 4-4 */
    UART0->UARTCC = 0; /* use system clock */
    UART0->UARTLCRH = 0x60; /* 8-bit, no parity, 1-stop bit, no FIFO */
    UART0->UARTCTL = 0x301; /* enable UART0, TXE, RXE */

    /* UART0 TX0 and RX0 use PA0 and PA1. Set them up. */
    GPIODEN_APB_PORTA |= 0X3 ; //U0Rx , U0Tx

    GPIOAFSEL_APB_PORTA |= 0X3 ; //U0Rx , U0Tx

    GPIOPCTL_APB_PORTA |= 0X11 ; //U0Rx , U0Tx
    // TRANSMITE_UART_CHAR(UART_0 ,'y');
    // TRANSMITE_UART_CHAR(UART_0 ,'e');
    // TRANSMITE_UART_CHAR(UART_0 ,'s');
    // TRANSMITE_UART_CHAR(UART_0 ,'\n');
    // TRANSMITE_UART_CHAR(UART_0 ,'\r');
    while(1)
    {
    TRANSMITE_UART_CHAR(UART_0 ,'y');
    TRANSMITE_UART_CHAR(UART_0 ,'e');
    TRANSMITE_UART_CHAR(UART_0 ,'s');
    TRANSMITE_UART_CHAR(UART_0 ,'\n');
    TRANSMITE_UART_CHAR(UART_0 ,'\r');
    }
    }

    Let me know what your thoughts are.

    Thanks and regards,

    Art

  • Attached is the customer source code.

    UAERT2(2).rar

    Thanks and regards,

    Art

  • Hello Art,

    We will not do code review for DRM code.

    Best Regards,

    Ralph Jacobi

  • I understand Ralph but customer is persistent. According to him, he do a custom code just like tivaware code and he debugged both with the same register change but his code didn't work.

    He does not know why, he is thinking that the problem could be something in his start-up code (provided .rar).

    Maybe there is something else we can do to extend support to the customer?

    Thanks and regards,

    Art

  • Hi Ralph,

    Apologies but the customer insist to forward this code to you though I already informed him that we do not do code review for DRM code.

    UART_TEST1.rar

    Just let me know in case you found something.

    Thanks and regards,

    Art

  • Ralph is out on vacation. As stated, we do not do DRM style code review. You should first provide scope or logic analyzer capture of the UART pins so it is easier to give feedback on what happens. 

  • Hello Art,

    We discussed this further due to customers insistence but we are holding the stance that we will not do a code review for non-TivaWare code.

    Regarding the situation, if we can get some better details on what is going wrong, then perhaps we can offer some sort of guidance.

    I've seen it both said that it works fine but causes noise, and that the code doesn't work at all. It's really confusing at this point what is even the problem being faced. As Charles said, if we can get some captures of the UART communications, maybe that will help us be able to offer some pointers at least.

    Best Regards,

    Ralph Jacobi

  • Thanks for the support guys! I'll let you know once I got feedback from the customer.

    Thanks and regards,

    Art