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.

Difference between LM3S9B92 and LM4F232H5QD UARTs?

Hello,

I have development boards for the LM3S9B92 and the LM4f232H5QD.  When I hook up the LM3S9B92's UART0 (PA0, PA1) and UART1 (PD2, PD3) to my PC via an RS-232 interface, all communication happens as expected, at any baud from 9600 to 115200.

When I hook up the LM4F232H5QD's UART0 (PA0, PA1) and UART1 (C4, C5) with the same RS-232 interface, the communication is 'messed up'.

When I transmit a stream of 20 bytes with uniform bits, I do get 20 bytes on the other end - though not necessarily the right ones:

0x00:

00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00

0xFF:

FC  FC  FC  FC  FC  FC  FC  FC  FC  FC  FC  FC  FC  FC  FC  FC  FC  FC  FC  FC

When I transmit bytes with bits that differ, the length seen on the other end varies:

0x01:

3C  00  3C  00  3C  00  3C  00  3C  00  3C  00  3C  00  3C  00  3C  00  3C  00  3C  00  3C  00  3C  00  
3C  00  3C  00  3C  00  3C  00  3C  00  3C  00  3C  00 

0x10:

C0  3C  00  C0  3C  00  C0  3C  00  C0  3C  00  C0  3C  00  C0  3C  00  C0  3C  00  C0  3C  00  C0  3C  
00  C0  3C  00  C0  3C  00  C0  3C  00  C0  3C  00  C0  3C  00  C0  3C  00  C0  3C  00  C0  3C  00  C0  
3C  00  C0  3C  00  C0  3C  00 

This seems to indicate that my baud rate isn't actually what I'm setting it to.  I've tried switching the UART from being clocked from the precision internal oscillator to the system clock, with no success.  I've also tried replacing the UART Stellarisware ROM calls I was using with normal Stellarisware calls, in case there was a bug in those.

I see nothing in the errata, examples, or this forum for the LM4F 232H5QD to explain the problem.  I'm not sure if this problem can arise from the microcontroller being damaged, so I may end up trying again on a new board.  Any other suggestions?

Thanks.

  • I tried hooking up a new LM4F232H5QD board and got the same result.

  • Without looking at your code, I'm not sure what to suggest.  I use UART0 (PA0/PA1) all the time with my LM4F232.  I threw together a quick test of UART1 (PC4/PC5) and saw no problems at 115200 and 9600 baud.

    Are you using the LM4F232H5QD Stellaris board?  And you're configuring the clock to recognize the 16MHz crystal?  Do you have a scope so you can look at the actual RS-232 bit speed.

    This is what I used to test UART1:

    int main(void)
    {
        // Set the clocking to run from MOSC, with PLL.
        SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

        // Configure UART1 as STDIO at 115200 baud
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
        SysCtlDelay(100);

        GPIOPinConfigure(GPIO_PC4_U1RX);
        GPIOPinConfigure(GPIO_PC5_U1TX);
        GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5);
        UARTStdioInitExpClk(1, 115200);

        // display a message repeatedly
        while (1)
        {
            UARTprintf ("hello world\n");
            SysCtlDelay (SysCtlClockGet() / 3);
        }
    }

    KC Witte

  • I am using TI development boards to do these tests (LM4F232H5QD rev A1 and LM3S9B92 rev B1).

    It turns out that the problem was related to clocking the UART from the PIOSC (precision internal oscillator).  For some strange reason, including a call to UARTClockSourceSet() works correctly when I call it in my application code for the LM3S9B92, but doesn't work for the LM4F in my application code or when it is inserted in the example you supplied on either the LM3S or LM4F board.

    What's wrong with the following?  Can you get it to work?

    int main(void)
    {
        // Set the clocking to run from MOSC, with PLL.
        SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

        // Configure UART1 as STDIO at 115200 baud
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
        SysCtlDelay(100);

        GPIOPinConfigure(GPIO_PA0_U0RX);
        GPIOPinConfigure(GPIO_PA1_U0TX);
        GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

        UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

        UARTStdioInitExpClk(0, 115200);

        // display a message repeatedly
        while (1)
        {
            UARTprintf ("hello world\n");
            SysCtlDelay (SysCtlClockGet() / 3);
        }

    }

    Thanks.

  • I think the problem is that UARTStdioInitExpClk() expects the UART to be running from the system clock.  That's the source of the MAP_SysCtlClockGet() as a parameter in the call to MAP_UARTConfigSetExpClk().

    You can either change UARTSTDIO.C to use 16000000 (the PIOSC frequency) instead of MAP_SysCtlClockGet(), or undo the damage by adding a call to UARTConfigSetExpClk() to your code; i.e., have:

         UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

        UARTStdioInitExpClk(0, 115200);

        UARTConfigSetExpClk(UART0_BASE, 16000000, 115200, (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE | UART_CONFIG_WLEN_8));

    I haven't looked into why the behavior differs between LM3S9B92 and LM4F232H5QD; I just verified that this code change appears to work with UART1 on an LM4F232H5AD.

    KC Witte

  • Okay, I now feel confident that all of the problems are software-related on my end.  Thanks!

  • The reason I didn't see this problem on the LM3S9B92 is because the function call UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC) has no effect!  The UART is still definitely being clocked from the system clock.

  • Ben,

    As noted in the Driver Library User's Guide, the UARTClockSourceSet function does not work on all Stellaris devices.  Only the LM4F devices can have an alternate clock source for the UART baud clock.

    We provide an app note that could be a helpful reference for you: Differences Among Stellaris Product Classes (Rev. A)

    Regards,

    Sue