Playing with the UART on the TI Stellaris Launchpad.

I just started playing around with the TI Stellaris Launchpad a couple of days ago.

The Launchpad is a pretty powerful little dev board. It has  ARM Cortex-M4F core at it heart. The really awesome thing is that there’s a Full fledged  debugger built-in which makes it a really good board to start with ARM micros.

I was fiddling with the UART trying to setup two way communication with the micro. so i started out with the uart_echo project included in the Stellarisware bundle.

The uart_echo code works with the UART0 of the micro and i wanted to get it running on the UART1, Sound simple right? But for a Newbie to this micro-controller it might be a bit difficult. That was what happened it took some amount of digging around the internets and the documentation to get the code to do what i wanted but finally it started working

Here’s what i ended up doing. First i reconfigured all the I/Os the UART1 Pins can be used either on PB0,1 or on PC4.5. I used the PB0 and PB1 pins. changed the code in all the other relevant places in the main code, tried running the code . I got the “Enter Text” messgae on the terminal. It means the Tx was working fine. but i could get a echo back from the micro. The uart_echo uses the uart receive interrupt which was not being triggered. So i needed to get the interrupt triggered when the data comes in on the RX pin. by the way i did try the echo function running in the while loop and that confirmed that the physical connection was good and that the code was working.

I stumbled upon a forum post by another person facing similiar problems where he suggested that i make changes to the interrupt vector table in the startup_ccs.c file  i simply replaced the IntDefaultHandler with the UART1IntHandler which is the interrupt handler for UART1 and like magic the code started working! Here’s the final Ti Code Composer studio v5.2 project. You can Import the code directly into CCS using the import option.

Planning to get the PWM working now…..will post on it soon…

3 responses to “Playing with the UART on the TI Stellaris Launchpad.

  1. In what way did you connect your input to uart1? I am wondering because I am trying to establish a Bluetooth connection to uart1 and am having difficulty. Like you, I can get the uart_echo code to run perfectly using uart0; however, once I switch everything to use uart1, no luck.

    I have confirmed that the transmit pin from the BT module connected to the Rx pin of the Stellaris is actually receiving the data. My thoughts are either my pins are declared incorrectly, or my interrupt is not functioning correctly. I am also using the uart to perform PWM for power control reasons. Any tips appreciated!

    Code:

    int
    main(void)
    {
    //
    // Enable lazy stacking for interrupt handlers. This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    FPUEnable();
    FPULazyStackingEnable();

    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
    SYSCTL_XTAL_16MHZ);

    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    // Enable the GPIO pins for the LED (PF2).
    //
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);

    //
    // Enable the peripherals used by this example.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    //
    // Enable processor interrupts.
    //
    IntMasterEnable();

    //
    // Set GPIO PB0 and PB1 as UART pins.
    //
    GPIOPinConfigure(0x00010005);
    GPIOPinConfigure(0x00010405);
    GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Configure the UART for 115,200, 8-N-1 operation.
    //
    UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200,
    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
    UART_CONFIG_PAR_NONE));

    //
    // Enable the UART interrupt.
    //
    IntEnable(INT_UART1);
    UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT);

    //
    // Prompt for text to be entered.
    //
    UARTSend((unsigned char *)”33[2JEnter text: “, 16);

    //
    // Loop forever echoing data through the UART.
    //
    while(1)
    {
    }
    }

    • Please check my startup_ccs.c file and compare it with the one you have. The problem you are facing seems to be a issue with the interrupt vector setup. Also I used PB0 and PB1 for the UART pins. Try running the code attached in the blog post on your launchpad, and see if that works. if not let me know what error you are getting.

      Do let me know how it goes! Good luck!
      Murli

  2. I appreciate your response! I am familiar with the need to rename the interrupt handler and declare it in the startup file. I have tried running your code and cannot get an echo on the Putty terminal window. Even the prompt “Enter text:” does not get displayed.

    One difference I noticed between our code is code composer forces me to use the actual hex address of the uart Rx and Tx pins found in the pin_map header file when I configure them. They are 0x00010005 and 0x00010405 respectively. The only other difference is I took of the ROM_ dictation which should not change the functionality of the code.

    Again, thanks for your help. I’ve been stuck on this for several weeks.

    -Taylor

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s