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.

MSP430 LaunchPad, basic uart

Other Parts Discussed in Thread: MSP430G2553, MSP430G2231, ENERGIA

Hi, Im really beginner with MSP430 LaunchPad and uP programing as well. I'd like to know how to works UART communication. I have read the family guide, but anyway I don't understand. Could u provide me some easy code example...for example HT will read char from keyboard. Thank u

  • Jan,

    there is a code example archive that can be found in any of the "Value Line" device's product folders:

    http://www.ti.com/lit/zip/slac463

    A good starting point for you would probably be msp430g2xx1_ta_uart9600.c (also attached) that shows a full-duplex Timer_A-based UART implementation performing an echo function plus outputting all 8 bits of any received character to port pins.

    Regards,
    Andreas

  • Here is another example:

    http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/p/73346/266565.aspx#266565

  • Andreas thank u very very, code is working very well. Now Im trying to understand it, it's not so easy as I thought. First I should to learn how works timer and interrupt. Later I want to work with AT commands for to programing GSM module. Do u have some experiences with it? Thanks

     

  • Hi All,

    I am new to this forum also to work with microcontroller. Currently I am verifying UART program with two launchpad msp430g2231 and msp430g2553 which ends up in failure. I couldnt get the output in my hyperterminal.

    Initially I thought of verifying UART functionality separately in each board. I took the above program to start with. I have connected the TXD and RXD pin with a wire so that I can verify my output in hyperterminal. But my hyperterminal is inactive. I couldnt type anything. I dont know where the problem is.

    Can anyone help me whether this is right way to approach?

  • @ Raji Bala

    Which version(Revision) of the MSP430 Launchpad are you using ?

    Did you change the header positions on the J3 header(according to the board Revision) for the UART to work with the PC ?

    Also, if you are using the MSP430G2231, make sure that the code that you are running is for Software UART emulation.

    If you believe that you have a working code running in your MCU and you have made the appropriate connections and still are not getting the output, then its better to install Energia and try the example "Serial" program first, which will help you verify the hardware connections.

    Regards

  • Hi Kevin,

           Thank you so much for your comments.

    I am using Rev1.4 for MSP430G2231 and Rev1.5 for MSP430G2553.

    Whether I need to change header position in both ?

    Thanks,

    Raji

  • Okay..
    So, if you are planning to test the Launchpad's individually, lets say, the Rev 1.5 with G2553. 
    Do the following:
    1. Invert the positions of the headers on RXD,TXD , as shown in the figure below.

    2. Flash the attached code into the MSP using CCS
         The code echoes back the character typed from the PC back to the PC, so that you can observe it on the COM port monitor.

    //******************************************************************************
    //   MSP430G2xx3 Demo - USCI_A0, 9600 UART Echo ISR, DCO SMCLK
    //
    //   Description: Echo a received character, RX ISR used. Normal mode is LPM0.
    //   USCI_A0 RX interrupt triggers TX Echo.
    //   Baud rate divider with 1MHz = 1MHz/9600 = ~104.2
    //   ACLK = n/a, MCLK = SMCLK = CALxxx_1MHZ = 1MHz
    //
    //                MSP430G2xx3
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 |
    //          --|RST          XOUT|-
    //            |                 |
    //            |     P1.2/UCA0TXD|------------>
    //            |                 | 9600 - 8N1
    //            |     P1.1/UCA0RXD|<------------
    //
    //   D. Dang
    //   Texas Instruments Inc.
    //   February 2011
    //   Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
    //******************************************************************************
    #include  "msp430g2553.h"
    
    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      BCSCTL1 = CALBC1_1MHZ;                    // Set DCO
      DCOCTL = CALDCO_1MHZ;
      P1SEL = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD
      P1SEL2 = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD
      UCA0CTL1 |= UCSSEL_2;                     // SMCLK
      UCA0BR0 = 104;                            // 1MHz 9600
      UCA0BR1 = 0;                              // 1MHz 9600
      UCA0MCTL = UCBRS0;                        // Modulation UCBRSx = 1
      UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
      IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt
    
      __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, interrupts enabled
    }
    
    //  Echo back RXed character, confirm TX buffer is ready first
    #pragma vector=USCIAB0RX_VECTOR
    __interrupt void USCI0RX_ISR(void)
    {
      while (!(IFG2&UCA0TXIFG));                // USCI_A0 TX buffer ready?
      UCA0TXBUF = UCA0RXBUF;                    // TX -> RXed character
    }
    

     

    3. Open a Serial Monitor (Putty,Hyperterminal, or you could use the one that come with Energia, the Ardunio based programming platform for MSP430) and type in some character and observe the echo on the monitor.

    If you are still not able to view it using the Serial Monitor of your choice, I suggest you download Energia and use its serial monitor (it always works for me in this way, even when other monitors fail, due to some unknown errors) 

  • Hi Kevin,

    Whatever you mentioned is communication between microcontroller and PC through RS232.

    As of now I am not having level converter so I tried to transmit and receive the data in the same controller. (I have connected the Tx pin to Rx). Likewise I verified in both the boards. But when I tried to communicate between both the boards(Connected TX pin of MSP430G2231 and RX pin of MSP430G2553),  I didnt receive the data in the receiver side.

    Whether we can verify by this method or it is not possible to verify? Can you pls clarify me.

    Thanks,

    Raji

  • I think you rae not aware of the fact that the Launchpad has an onboard USB emulator, which takes care of relaying data between the MCU and the PC.
    Which means, you don;t require any external hardware to interface the UART of the MCU with the PC. Just make the jumper connections as I have indicated in my previous reply and you can observe the Launchpad as a COM Port in your Windows "Device Manager" , under "Ports" 

  • I think you rae not aware of the fact that the Launchpad has an on-board USB emulator, which takes care of relaying data between the MCU and the PC.
    Which means, you don;t require any external hardware to interface the UART of the MCU with the PC. Just make the jumper connections as I have indicated in my previous reply and you can observe the Launchpad as a COM Port in your Windows "Device Manager" , under "Ports" 

  • I think you are not aware of the fact that the Launchpad has an on-board USB emulator, which takes care of relaying data between the MCU and the PC.
    Which means, you don;t require any external hardware to interface the UART of the MCU with the PC. Just make the jumper connections as I have indicated in my previous reply and you can observe the Launchpad as a COM Port in your Windows "Device Manager" , under "Ports" 

**Attention** This is a public forum