Setting up UARTs on several micros

Brian from teho Labs wrote a tutorial on how to setup serial UART communication on various microcontrollers. UART code examples for the Arduino, ATMEGA168, MSP430, STM32, and LM3S are provided.

From his nice writeup it is easy to see why the Arduino is so popular. Being a library based platform, only two lines of code are needed to setup UART on a Arduino. Considerably more typing is required to get other microcontrollers working.

Via the forum.

Join the Conversation


  1. great comparison!
    using a PSoC3/5 is pretty easy on the code too:

    UART_PutString(“Hi There “);

    all the other things are configured in the GUI (baud bits, etc) but can also be set in function calls.
    Also can add numerous UART and send them to whatever pins

  2. For dspic33, from the web platform docs:

    2 //assign pin 14 to the UART1 RX input register
    3 //RX RP14 (input)
    4 U1RXR_I = 14;
    5 //assign UART1 TX function to the pin 15 output register
    6 //TX RP15 (output)
    7 RP15_O=U1TX_O;

    First assign the UART to whatever pins you want to use

    1 //setup UART
    2 U1BRG = 85; //86@80mhz,
    3 U1MODE = 0; //clear mode register
    4 U1MODEbits.BRGH = 1; //use high precision baud generator
    5 U1STA = 0; //clear status register
    6 U1MODEbits.UARTEN = 1; //enable the UART RX
    7 IFS0bits.U1RXIF = 0; //clear the receive flag

    Setup the UART speed and stuff

    Sorry, I don’t have the actual send and check/receive stuff.

Leave a comment

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.