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.

About using MSP430 IN serial communication

Other Parts Discussed in Thread: MSP430F5529

Hi,

 

i am working on one project in which i have to get data as serially at one side of MCU and transmitte  that data as serially at other side .

 

For this purpose i need two UART. So please give me guidance for this.

And i have one other quetion is that if i will use a MCP430  MCU than any source code for UART AND serial communication and also Enviorment for run that code with my cose will be given by TI ?

 

Please Guide me for this Porblem

Thank You.

Regards.

Heena Kalgude

  • Do you just need 2 UARTs on an MSP430 and no other specific requirements?

    If there aren't any other requirements there are a few different families you can use. I would personally recommend one of the newer 5 series devices though.

    For a limited amount of code you can use the free versions of IAR or CCS. For just using 2 UARTs on an MSP430 your code should be very very small.

    TI has example code for using the UARTs. Setting up 2 UARTS on an MSP430 requires only a few lines of code.

    If you go with newer processors (like the 5xxx series) you can use the Spy-by-wire debugger on the MSP430 launchpad because it is very cheap, and easier to wire up.

    The launchpad kits are only $4.30 each.

    As an example on my MSP430F5529, here is the code to enabled 2 UARTs at 4800 and 9600 baud from a 4MHz crystal. After this setup code you can use interrupt service routines to process received messages, and function calls (or ISRs) to send messages.

      // Enable USCI0A in UART mode 4800 baud
      P3SEL = BIT3+BIT4;      // P3.3,4 = USCI_A0 TXD/RXD

      UCA0CTL1 |= UCSWRST;                    // **Put state machine in reset**
      UCA0CTL1 |= UCSSEL__SMCLK;      // CLK = SMCLK
      UCA0BR0 = 0x41;                                  // clock: 4000000Hz, desired baud rate: 4800bps
      UCA0BR1 = 0x03;                                 // division factor: 833.3
      UCA0MCTL = 0x09;                              // effective baud rate: 4800.19bps
                                                                       // maximum error: 0.1666us   0.08%
      UCA0CTL1 &= ~UCSWRST;             // **Initialize USCI state machine**
      UCA0IE |= UCRXIE;                             // Enable USCI_A0 RX interrupt
     
      // Set  USCIA1 to UART mode 9600 baud
      P4SEL = BIT4 + BIT5;
        
      UCA1CTL1 |= UCSWRST;                     // **Put state machine in reset**
      UCA1CTL1 |= UCSSEL__SMCLK;      // CLK = SMCLK
      UCA1BR0 = 0xA0;                                   // clock: 4000000Hz, desired baud rate: 9600bps
      UCA1BR1 = 0x01;                                  // division factor: 416.7
      UCA1MCTL = 0x5B;                              // effective baud rate: 9599.23bps
                                                                       //maximum error: 0.1666us   0.16%
      UCA1CTL1 &= ~UCSWRST;            // **Initialize USCI state machine**

      UCA1IE |= UCRXIE;                          // Enable USCI_A1 RX interrupt


    //Example Interupt Service Routine for UART A1
    #pragma vector=USCI_A1_VECTOR
    __interrupt void USCI_A1_ISR(void)
    {
      switch(__even_in_range(UCA1IV,4))
      {
      case 0:break;                                            // Vector 0 - no interrupt
      case 2:                                                        // Vector 2 - RXIFG
         while (!(UCA1IFG&UCTXIFG));            // USCI_A1 TX buffer ready?
         UCA1TXBUF = UCA1RXBUF;              // TX -> RXed character 
         break;
      case 4:break;                                            // Vector 4 - TXIFG
      default: break;
      }
    }

  • heena kalgude said:
    For this purpose i need two UART

    Not necessarily. It is not mandatory that the TX signal of an UART is connected to the same endpioint as the RX sinde, as long as the baudrates are identical. UART serial transmissions are asynchroneous and bi-directional. That menas that each direction is independent in terms of connection endpoint and tiem of transmission. Only the baudrate is common for both.Of course if you need to change the baudrate, then you in deed need two UARTs.

    heena kalgude said:
    So please give me guidance for this.

    Which kind of guidance? Which MSP to choose? How to do it in general? How to setup an UART (which depends on the actual device,a s there are UART and USCI modules), how to calculate the baudrate settings?

    heena kalgude said:
    any source code for UART AND serial communication and also Enviorment for run that code with my cose will be given by TI ?

    There are several code examples available.

    However, if you think your problem has already been resolved in detail, and a complete solution were available, don't you think then that there would be no need for your project at all? TI is providing the processor, not complete solutions.

  • Please take a look at TI code examples:

    http://focus.ti.com/mcu/docs/mcuflashtools.tsp?sectionId=95&tabId=1538&familyId=342

    IDE links you may find at:

    http://focus.ti.com/mcu/docs/mcuprodmsptoolsw.tsp?sectionId=95&tabId=1203&familyId=342&toolTypeId=1#IDE

    Code Composer Studio v.4 is free up to 16 KB of code, IAR Embedded Testbench for 8KB.

    Regards,
    Piotr Romaniuk, Ph.D.
    ELESOFTROM

**Attention** This is a public forum