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.

MSP430FR5994: RECEIVING DATA BY USING UART

Part Number: MSP430FR5994


Hi everyone

I wanted to receive data from terminal of CCS through UART. I have fixed baudrate as 9600. And initialized an LED to blink when the data from terminal get matched. But when i write data through terminal the LED is not turning on and some garbage is printing on the terminal.So can someone please help me get the proper output. I'm sharing the code here.

/////////////////////////////////////////////////////////////////////////////////////////////////    MAIN.C   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <msp430.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <uart.h>

unsigned char addr[30]="";

void pin_setup()
{
P1DIR = 0x02;
P1OUT = ~0x02;
}


void clk_setp()
{
CSCTL0_H = CSKEY_H;
CSCTL1 = DCOFSEL_6; //8MHz |DCOFSEL_0 -1MHz
CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK; // Set SMCLK = MCLK = DCO
CSCTL3 = DIVA_1|DIVS__1|DIVM__1;
CSCTL0_H = 0;
}


void uart_config()
{
P2SEL0 &= ~(BIT0 | BIT1);
P2SEL1 |= (BIT0 | BIT1); // USCI_A0 UART operation
PM5CTL0 &= ~LOCKLPM5;
UCA0CTLW0=UCSWRST;
UCA0CTLW0 |=UCSSEL__SMCLK;
UCA0BRW = 52;
UCA0MCTLW |= UCOS16 | UCBRF_1 | 0x49;
UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
}


void UART_RECEIVE()
{
pin_setup();
__bis_SR_register(LPM0_bits|GIE);
sprintf(addr,"%s\r\n",RXData);
if(addr=="y")
{
P1OUT=0x02;
}
}


int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
clk_setp();
uart_config();

while(1)
{
UART_RECEIVE();
}

return 0;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   UART.H     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <msp430.h>
#include <stdint.h>
#include <stdbool.h>

volatile int Rx_index=0;
volatile unsigned int Rx_key=0;
volatile int Tx_index=0;
volatile unsigned int Tx_key=0;
int size=0;
unsigned char TXData[15]="";
unsigned char RXData[5]="";

#pragma vector = EUSCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
Rx_key=0;
RXData[Rx_index]=UCA0RXBUF;
if((RXData[Rx_index] == '\x0d'/*'\r'*/) || (RXData[Rx_index] == '\n')||(RXData[Rx_index] == '\r'))
{
__bic_SR_register_on_exit(CPUOFF|GIE);
UCA0IE &= ~UCRXIE;
Rx_index=0;
Rx_key=0;
break;
}
Rx_index++;
break;
case USCI_UART_UCTXIFG:
if(Tx_key==1)
{
if(Tx_index>size)
{
__bic_SR_register_on_exit(CPUOFF|GIE);
UCA0IE &= ~UCTXIE;
UCA0IE &= ~UCTXCPTIE;
Tx_key=0;
break;
}
UCA0TXBUF = TXData[Tx_index];
Tx_index++;
Tx_key=0;
}
break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG:
Tx_key=1;
UCA0IFG|=UCTXIFG;
break;
default: break;
}
}

  • Hi there,

    Maybe you can debug by step to see if the UCA0RXBUF is correct.

    I modified the example code, which initialization is same as your code. And everything seems ok.

    Or if you need, I can send you the code.

    Thanks and Best Regards

    Yuhao Zhao

  • Hi Yuhao,

    I Have debug the code it is stopping at the interrupt. Can you please share your code.That helps me. 

  • Hi there,

    First, maybe you can check that the UART is receiving data correctly. If the UART receiving is ok, then check if there is a problem with data processing. 

    The code is modified from the example code 'msp430fr599x_euscia0_uart_01.c'. It is just a simple code and its function is to send the received data back. 

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2015, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //  MSP430FR5x9x Demo - eUSCI_A3 UART echo at 9600 baud using BRCLK = 8MHz
    //
    //  Description: This demo echoes back characters received via a PC serial port.
    //  SMCLK/ DCO is used as a clock source and the device is put in LPM3
    //  The auto-clock enable feature is used by the eUSCI and SMCLK is turned off
    //  when the UART is idle and turned on when a receive edge is detected.
    //  Note that level shifter hardware is needed to shift between RS232 and MSP
    //  voltage levels.
    //
    //  The example code shows proper initialization of registers
    //  and interrupts to receive and transmit data.
    //  To test code in LPM3, disconnect the debugger.
    //
    //  ACLK = VLO, MCLK =  DCO = SMCLK = 8MHz
    //
    //                MSP430FR5994
    //             -----------------
    //       RST -|     P6.0/UCA3TXD|----> PC (echo)
    //            |                 |
    //            |                 |
    //            |     P6.1/UCA3RXD|<---- PC
    //            |                 |
    //
    //   William Goh
    //   Texas Instruments Inc.
    //   October 2015
    //   Built with IAR Embedded Workbench V6.30 & Code Composer Studio V6.1
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop Watchdog
    
    
        // Configure GPIO
        P2SEL0 &= ~(BIT0 | BIT1);
        P2SEL1 |= (BIT0 | BIT1);				// USCI_A3 UART operation
    
        // Disable the GPIO power-on default high-impedance mode to activate
        // previously configured port settings
        PM5CTL0 &= ~LOCKLPM5;
    
        // Startup clock system with max DCO setting ~8MHz
        CSCTL0_H = CSKEY_H;                     // Unlock CS registers
        CSCTL1 = DCOFSEL_3 | DCORSEL;           // Set DCO to 8MHz
        CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
        CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;   // Set all dividers
        CSCTL0_H = 0;                           // Lock CS registers
    
        // Configure USCI_A3 for UART mode
        UCA0CTLW0 = UCSWRST;                    // Put eUSCI in reset
        UCA0CTLW0 |= UCSSEL__SMCLK;             // CLK = SMCLK
        // Baud Rate calculation
        // 8000000/(16*9600) = 52.083
        // Fractional portion = 0.083
        // User's Guide Table 21-4: UCBRSx = 0x04
        // UCBRFx = int ( (52.083-52)*16) = 1
        UCA0BRW = 52;                           // 8000000/16/9600
        UCA0MCTLW |= UCOS16 | UCBRF_1 | 0x49;
        UCA0CTLW0 &= ~UCSWRST;                  // Initialize eUSCI
        UCA0IE |= UCRXIE;                       // Enable USCI_A3 RX interrupt
    
        __bis_SR_register(LPM3_bits | GIE);     // Enter LPM3, interrupts enabled
        __no_operation();                       // For debugger
    }
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=EUSCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(EUSCI_A3_VECTOR))) USCI_A3_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
        switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))
        {
            case USCI_NONE: break;
            case USCI_UART_UCRXIFG:
                while(!(UCA0IFG&UCTXIFG));
                UCA0TXBUF = UCA0RXBUF;
                __no_operation();
                break;
            case USCI_UART_UCTXIFG: break;
            case USCI_UART_UCSTTIFG: break;
            case USCI_UART_UCTXCPTIFG: break;
            default: break;
        }
    }
    

    Thanks and Best Regards

    Yuhao Zhao

  • Hi Yuhao,

    Thankyou so much For the code it is working great. Again UART is not receiving on my main code. I have to set the RTC values by using UART. But data is not getting into buffer.I'm sharing the code here please help me.

    ///////////////////////   main.c  ///////////////////////////
    
    #include <msp430.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdint.h>
    #include <stdlib.h>
    #include <rtc.h>
    
    unsigned char addr[30]="";
    
    
    
    void pin_setup()
    {
       // P1DIR |= BIT0; //Set P1.0 (red LED) to output
        P1DIR = 0x03; //Set P1.0 to output direction
    
        //P1OUT &=~0X02;
        PM5CTL0=LOCKLPM5;
    }
    void clk_setp()
    {
         CSCTL0_H = CSKEY_H;
         CSCTL1 = DCOFSEL_6; //8MHz |DCOFSEL_0 -1MHz
         CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;  // Set SMCLK = MCLK = DCO
         CSCTL3 = DIVA_1|DIVS__1|DIVM__1;
         CSCTL0_H = 0;
    }
    
    void RTC_clk_setup()
    {
       /* P1DIR |= BIT0;
        P1OUT &= ~BIT0;// Set P1.0 as output*/
        PJSEL0 = BIT4 | BIT5;                   // Initialize LFXT pins
       // Disable the GPIO power-on default high-impedance mode to activate
       // previously configured port settings
        PM5CTL0 &= ~LOCKLPM5;
    
       // Configure LFXT 32kHz crystal
        CSCTL0_H = CSKEY_H;                     // Unlock CS registers
        CSCTL4 &= ~LFXTOFF;                     // Enable LFXT
         do
         {
            CSCTL5 &= ~LFXTOFFG;                  // Clear LFXT fault flag
            SFRIFG1 &= ~OFIFG;
         } while (SFRIFG1 & OFIFG);              // Test oscillator fault flag
           CSCTL0_H = 0;                           // Lock CS registers*/
    }
    
    
    
    void uart_config()
     {
         P2SEL0 &= ~(BIT0 | BIT1);
         P2SEL1 |= (BIT0 | BIT1);                // USCI_A0 UART operation
         PM5CTL0 &= ~LOCKLPM5;
         UCA0CTLW0=UCSWRST;//eUSCI in reset mode(disabling) and this will automatically SETS the UCTXIFG and RESETS the UCRXIFG,UCRXIE,UCTXIE
         UCA0CTLW0 |=UCSSEL__SMCLK;//CLOCK is SMCLK=8MHZ
         UCA0BRW = 52;
         UCA0MCTLW |= UCOS16 | UCBRF_1 | 0x49;
         UCA0CTLW0 &= ~UCSWRST;                  // Initialize eUSCI
         UCA0IE |= UCRXIE;                       // Enable USCI_A0 RX interrupt
     }
    
    void print(unsigned char *str)
    {
        strcpy(Data, str);
        size = strlen(Data);
        Tx_index=0;
        UCA0IE |= UCTXIE | UCTXCPTIE;
        UCA0TXBUF=Data[Tx_index];
        Tx_index++;
        __bis_SR_register(LPM0_bits|GIE);
        }
    
    
    void RTC_init()
    {
           print("SET TIME\r\n");
           RTC_clk_setup();
           RTCCTL0_H = RTCKEY_H;                   // Unlock RTC
           RTCCTL0_L = RTCTEVIE_L | RTCRDYIE_L;    // enable RTC read ready interrupt
                                                   // enable RTC time event interrupt
           RTCCTL13 = RTCBCD | RTCHOLD | RTCMODE;  // RTC enable, BCD mode, RTC hold
           RTCYEAR = 0x2022;                       // Year = 0x2022
           RTCMON = 0x11;                           // Month = 0x10 = nov
           RTCDAY = 0x02;                          // Day = 0x26 = 26th
           RTCDOW = 0x03;                          // Day of week = 0x04 = thurs
           print("ENTER HOURS: \r\n");
           UCA0IE |= UCRXIE | UCTXCPTIE;
          __bis_SR_register(LPM0_bits | GIE);
           RTCHOUR = RXData; // Hour = 0x23
          // printf("%x",RTCHOUR);
           print("ENTER MINITUS: \r\n");
           UCA0IE |= UCRXIE | UCTXCPTIE;
           __bis_SR_register(LPM0_bits | GIE);
           RTCMIN = RXData;
          // printf("%x",RTCMIN);
           print("ENTER SECONDS: \r\n");
           UCA0IE |= UCRXIE | UCTXCPTIE;// Minute = 0x00
           __bis_SR_register(LPM0_bits | GIE);
           RTCSEC = RXData; // Seconds = 0x00
          // printf("%x",RTCSEC);
           RTCCTL13 &= ~(RTCHOLD);                 // Start RTC
    
         //  __bis_SR_register(LPM3_bits | GIE);     // Enter LPM3 mode w/ interrupts enabled
           __bis_SR_register(GIE);     // Enter LPM3 mode w/ interrupts enabled
           __no_operation();
           return 0;
    }
    
    
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop Watchdog Timer
        clk_setp();
        uart_config();
        RTC_init();
        pin_setup();
        while(1)
        {
            sprintf(addr, "%x:%x:%x\r\n", hours,mins,secs);
             print(addr);
    
            __delay_cycles(8000000);
           }
    }
    
    
    
    /////////////////////////  rtc.h   ////////////////////////////////
    
    
    #include <msp430.h>
    #include <stdint.h>
    #include <stdbool.h>
    
    volatile int Rx_index=0;
    volatile unsigned int Rx_key=0;
    volatile int Tx_index=0;
    volatile unsigned int Tx_key=0;
    int size=0;
    unsigned char Data[15]="";
    unsigned char RXData[5]="";
    unsigned char time_1[]="11:45:00";
    unsigned char time_2[]="11:47:00";
    unsigned int hr=11;
    unsigned int min1=45;
    unsigned int min2=47;
    int secs=0;
    int hours=0;
    int mins=0;
    int day=0;
    int month=0;
    int year=0;
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=RTC_C_VECTOR
    __interrupt void RTC_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(RTC_C_VECTOR))) RTC_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
        switch(__even_in_range(RTCIV, RTCIV__RT1PSIFG))
        {
            case RTCIV__NONE:      break;       // No interrupts
            case RTCIV__RTCOFIFG:  break;       // RTCOFIFG
            case RTCIV__RTCRDYIFG:              // RTCRDYIFG
                P1OUT ^= 0x01;// Toggles P1.0 every second
                hours=RTCHOUR;
                mins=RTCMIN;
                secs=RTCSEC;
                day=RTCDAY;
                month=RTCMON;
                year=RTCYEAR;
                 break;
            case RTCIV__RTCTEVIFG:              // RTCEVIFG
                __no_operation();               // Interrupts every minute - SET BREAKPOINT HERE
                break;
            case RTCIV__RTCAIFG:   break;       // RTCAIFG
            case RTCIV__RT0PSIFG:  break;       // RT0PSIFG
            case RTCIV__RT1PSIFG:  break;       // RT1PSIFG
            default: break;
        }
    }
    
    
    
    #pragma vector = EUSCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    {
        switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))
        {
            case USCI_NONE: break;
            case USCI_UART_UCRXIFG:
                Rx_key=0;
                RXData[Rx_index]=UCA0RXBUF;
                if((RXData[Rx_index] == '\x0d'/*'\r'*/) || (RXData[Rx_index] ==  '\n')||(RXData[Rx_index] == '\r'))
                {
                    __bic_SR_register_on_exit(CPUOFF|GIE);
                    UCA0IE &= ~UCRXIE;
                    Rx_index=0;
                    Rx_key=0;
                    break;
                }
                Rx_index++;
                break;
            case USCI_UART_UCTXIFG:
                if(Tx_key==1)
                {
                    if(Tx_index>size)
                    {
                        __bic_SR_register_on_exit(CPUOFF|GIE);
                        UCA0IE &= ~UCTXIE;
                        UCA0IE &= ~UCTXCPTIE;
                        Tx_key=0;
                        break;
                    }
                    UCA0TXBUF = Data[Tx_index];
                    Tx_index++;
                    Tx_key=0;
                }
                break;
            case USCI_UART_UCSTTIFG: break;
            case USCI_UART_UCTXCPTIFG:
                Tx_key=1;
                UCA0IFG|=UCTXIFG;
                break;
            default: break;
        }
    }

  • Maybe it's related to interrupt settings. I will check the code later.

  • UCA0IE |= UCTXIE | UCTXCPTIE;

    Bad idea. See errata USCI42.

  • Hi David,

    Thankyou for your response. I will check again. But I'm sorry to say that I did'nt face problem with that line because i have read the RTC values on terminal. Now i started facing problem when i started modifying the code to SET the RTC values by using UART receive. 

  • Hi Yuhao,

    First I wanted to read the string from UART before going into main program. I'm getting data from UCA0RXBUF to the RXData. But it is not getting from RXData to data variable in the piece of code below. 

    void RXdata()
    {
    unsigned int data;
    int i;
    UCA0IE |= UCRXIE;
    __bis_SR_register(LPM0_bits | GIE);
    data=RXData;

    }

    I have passed msp430 as a data from UART terminal. I'm sharing the complete program  please help me to get the data.

    //////////////////////// main.c  /////////////////////////////
    
    #include <msp430.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdint.h>
    #include <stdlib.h>
    #include <uart.h>
    unsigned char data[20]="";
    unsigned char receive_data;
     void pin_config()
     {
         P2SEL1|=BIT0|BIT1;
         P2SEL0 &=~BIT0|BIT1;
     }
     void clock_setup()
     {
         // Startup clock system with max DCO setting ~8MHz
         CSCTL0_H = CSKEY_H;                     // Unlock CS registers
        // CSCTL1 = DCOFSEL_3 | DCORSEL;           // Set DCO to 8MHz
         CSCTL1 = DCOFSEL_6 ;
         CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
         CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;   // Set all dividers
         CSCTL0_H = 0;
     }
     void UART_config()
     {
         UCA0CTLW0 = UCSWRST;                    // Put eUSCI in reset (p788)
         UCA0CTLW0 |= UCSSEL__SMCLK;             // CLK = SMCLK
         UCA0BRW = 52;                           
         UCA0MCTLW |= UCOS16 | UCBRF_1 | 0x49; 
         UCA0CTLW0 &= ~UCSWRST;                  // Initialize eUSCI
         _BIS_SR(GIE);
         UCA0IE = UCTXCPTIE;                       // Enable USCI_A0 RX interrupt
     }
    
     void RXdata()
     {
         UCA0IE |= UCRXIE;
         __bis_SR_register(LPM0_bits | GIE);
         data=RXData;
    
     }
     int main(void)
     {
         WDTCTL = WDTPW | WDTHOLD; // stop watchdog time
            pin_config();
            PM5CTL0&=~LOCKLPM5;
            clock_setup();
            UART_config();
    
            while(1)
            {
            RXdata();
            }
     }
     
     
     
     //////////////////////// uart.h  ///////////////////////////
     
     
     #include <msp430.h>
    #include <stdint.h>
    #include <stdbool.h>
    
    volatile int Rx_index=0;
    volatile unsigned int Rx_key=0;
    volatile int Tx_index=0;
    volatile unsigned int Tx_key=0;
    int size=0;
    unsigned char RXData[20]="";
    unsigned char Data[15]="";
    
    #pragma vector = EUSCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    {
        switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))
        {
            case USCI_NONE: break;
            case USCI_UART_UCRXIFG:
                Rx_key=0;
                RXData[Rx_index]=UCA0RXBUF;
                if((RXData[Rx_index] == '\x0d'/*'\r'*/) || (RXData[Rx_index] ==  '\n')||(RXData[Rx_index] == '\r'))
                {
                    __bic_SR_register_on_exit(CPUOFF|GIE);
                    UCA0IE &= ~UCRXIE;
                    Rx_index=0;
                    Rx_key=0;
                    break;
                }
                Rx_index++;
                break;
            case USCI_UART_UCTXIFG:
                if(Tx_key==1)
                {
                    if(Tx_index>size)
                    {
                        __bic_SR_register_on_exit(CPUOFF|GIE);
                        UCA0IE &= ~UCTXIE;
                        UCA0IE &= ~UCTXCPTIE;
                        Tx_key=0;
                        break;
                    }
                    UCA0TXBUF = Data[Tx_index];
                    Tx_index++;
                    Tx_key=0;
                }
                break;
            case USCI_UART_UCSTTIFG: break;
            case USCI_UART_UCTXCPTIFG:
                Tx_key=1;
                UCA0IFG|=UCTXIFG;
                break;
            default: break;
        }
    }

  • A few problems:

     UCA0IE = UCTXCPTIE;                       // Enable USCI_A0 RX interrupt

    The comment doesn't match the code.

    The use of a function and a variable name differing only in the capitalization of a single character is going to result in confusion.

    data=RXData;

    Both variables declared as character arrays. C will not copy the arrays but instead write the address of RXData[] to the first byte of data[].

    The best way to approach a problem like this is to start with something simple. Get that working and then add to it. Getting each bit working as you go.

**Attention** This is a public forum