MSP430G2553 Hardware UART

Hardware UART example for MSP430G2553 using mps430-gcc on Linux

This example shows how to use hardware UART through USCI_A on the TI Launchpad with a MSP430G2553 MCU. Receiving is done through interrupts.

Note: If you have an MSP430 MCU which does not support hardware UART (e.g. the MSP430G2231), have a look at this example.

1. Hardware Setup

The wiring for this example is as follows:

MSP430 To
RXD P1.1 TXD serial line
TXD P1.2 RXD serial line

Note: When using the TI Launchpad with a rev. before 1.5 (the once which shipped with the MSP430G2553 should all be >= 1.5 though) , “/dev/ttyACM0″ could be used as serial port at 9600 Bauds, but RX/TX must be crossed on the jumper bridge of the Launchpad.

Rx/TX Jumpers on Launchpad Rev. 1.4

RX/TX Jumpers on Launchpad Rev. 1.5

RX/TX Jumpers Launchpad Rev. 1.4

RX/TX Jumpers Launchpad Rev. 1.4

2. Get the sources

You can download the sources on github:

git clone http://github.com/wendlers/msp430-harduart.git

3. Compilation

This project is written for msp430-gcc on Linux (I used v4.5.3 which is available as package on ubuntu). For flashing the “mspdebug” tool was used (also from the Ubuntu package).

To compile the source just issue a:

make

This builds the firmware in the “bin” subdirectory in various formats.

4. Flashing

To flash the firmware to your Launchpad you could use the “flash-target” make target:

make flash-target

5. Doxygen Docs

If you installed doxygen on your system, you could generate the HTML-based documentation by calling:

make gen-docs

This will create the documentation under “doc/gen/html”.

6. Usage

Connecting your Launchpad should give you a new serial device “/dev/ttyACM0″. Connect to this port at 9600 bauds – e.g. by using screen:

screen /dev/ttyACM0 9600

A greeter is shown on the serial line, and you are prompted to press any key to start the echo demo. After the first keypress, “OK” is printed, and from then on, every character you type is echoed back. Every time, a character is received, the red LED on the launchpad is toggled. The green LED stadily blinks.

Note: to actually see the greeter in your screen session, you either need to start the screen before flashing the target, or just press reset on the Launchpad after you started your screen session.

Text on Serial Line after start

Text on Serial Line after start

Text on Serial Line after first key press

Text on Serial Line after first key press

15 Comments to MSP430G2553 Hardware UART

  1. JG's Gravatar JG
    9. Januar 2013 at 19:59 | Permalink

    It’s not working for me, on a launchpad Rev 1.5 with a 2553 (on a hardware UART position so jumpers like =|||) both leds stays on and screen stays completely black

    oh and the “captcha” in german can be a bit annoying ;)

  2. JG's Gravatar JG
    9. Januar 2013 at 20:14 | Permalink

    Please take my comment before with a pinch of salt, while playing with the leds to see where the problem is i had once the OK with a repeated character, never ever the invite (had to plugout/in the usb port tho…)

  3. JG's Gravatar JG
    9. Januar 2013 at 20:22 | Permalink

    Dear moderator, please explain that you have to manually reset the board with reset button once screen is launched (and this is not working 100% of time).

  4. JG's Gravatar JG
    9. Januar 2013 at 20:59 | Permalink

    sory mod, i’m talking a bit about my life here, had to address a proble with cdcacm. but i’m still having a small kind of a problem with your code (maybe it’s related to my machine) the banner appears, then i have to enter 2 chars before it repeats the second one, added a second time the
    c = uart_getc();
    uart_putc(c);
    uart_puts((char *)”\n\rOK\n\r”);
    code
    to make it happen twice and the problems stay the same, do not hesitate to mail me if you have an idea

  5. JG's Gravatar JG
    9. Januar 2013 at 21:19 | Permalink

    Hey stefan, forcing flow control on seemed to solve the problem
    (screen -f /dev/ttyACM0 9600) with the twiced echo sequence… you Rule ! every problem was on my side :)

  6. 19. Januar 2013 at 23:39 | Permalink

    Hi! Stefan Wendler, Your just awesome! Its working for me. Actually i have been trying for this UART communication past from two days. I have gone through so many data sheets, pdfs and i tested so many codes provided in CCS studio. i was scared while reading about UART in datasheet and pdfs related to MSP4302553. But finally you solved my problem in a simple manner. Thanks man! thanks A lot.

    Now i have to test the Transmission section….
    nice, useful and good site…

  7. tom's Gravatar tom
    23. Januar 2013 at 19:02 | Permalink

    Hi,
    Thanks for the code you shared!

    Could you elaborate a bit on the uart_set_rx_isr_ptr() routine, why is it needed, why it’s called with 0 as a parameter just to be checked in the ISR whether it’s 0? Is it to distinguish the “source” of the interrupt?
    One more thing that I cannot decipher is the syntax of line 62 (void uart_set_rx_isr_ptr(void (*isr_ptr)(unsigned char c)) ) and line 87 ((uart_rx_isr_ptr)(UCA0RXBUF);) – what is that?? ;)
    Thanks again!

  8. Robo's Gravatar Robo
    18. Februar 2013 at 12:02 | Permalink

    I’m using rev 1.4 board with MSP430G2553. I’ve connected P1.1 TXD to P1.2 RXD.

    I copied uart.c, uart.h, main.c to a new project file in Code Composer Studio.

    When I run the program, it continuously repeats the first two characters, i.e. if comment out the first uart_puts line, all it does is print MSMSMSMSMS…

    Both red and green LED remains lit, they do not flash. After pressing the reset button about 50 times, on one occasion the red LED was off and the green was blinking, but when I press reset it goes back to continuously printing the first two characters.

    I’m not sure what’s causing it to be ‘stuck’ on the first two chars.

  9. krishnak's Gravatar krishnak
    21. Februar 2013 at 12:35 | Permalink

    Thanks for the code, I tried on my board which is a 1.5 revision. I am using ubuntu 12.10 and I had the same problem as mentioned by JG when using screen. -f didn’t help

    I switched from screen to minicom and it seems to work

    minicom -b 9600 -D /dev/ttyACM0

    Whenever I press reset on the board, I get the greetings screen.

    After the greeting if I press a key that gets printed twice i.e if I press a – on the screen it shows aa

Leave a Reply

You must be logged in to post a comment.