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.

MSP-430EXPFR5739 UART Communication Problem

Other Parts Discussed in Thread: MSP430FR5739, MSP-EXP430FR5739

I have managed to get two of my fr5739s to communicate through UART (at 9600bd with ACLK at 1MHz), where one is transmitting data bytes and the other is receiving. However, I can't get them to do both. That is, if one board is set up for TX, then it cannot receive, and vice versa. I think it has something to do with the P2SEL0/P2SEL1 registers. In the data sheet here: http://www.ti.com/lit/ds/symlink/msp430fr5739.pdf on pg. 76 it states that P2SEL0 should be 0 and P2SEL1 should be 1 in order to set the pins (2.0 TX and 2.1 RX) to TX/RX, but my receive function will not work if the TX bit in P2SEL1 is set to 1. I have spent a lot of time trying to figure this problem out, and I would greatly appreciate any advice that the forum has to offer.

rx.c

#include <msp430fr5739.h>
#include <stdint.h>


volatile uint16_t g_counter = 25000;
volatile uint8_t g_data = 0;

int main(void) {

/* 1. Disable the Watchdog timer. */
WDTCTL = WDTPW + WDTHOLD;

/* 2. Enable LED1-4 for output. */
PJDIR |= BIT3 + BIT2 + BIT1 + BIT0;
PJOUT &= ~(BIT3 + BIT2 + BIT1 + BIT0);

PJOUT |= BIT0;
do g_counter--;
while(g_counter != 0);

/* 3. Configure clock settings. */
CSCTL0_H = 0xA5;                      // Write CSKEY password to configure clock settings
CSCTL1 &= ~DCORSEL;                   // Set DCO to 8MHz
CSCTL1 |= DCOFSEL1 | DCOFSEL0;
__delay_cycles(4);                    // Allow the DCO to settle at 8MHz
CSCTL2 &= ~SELA2;                     // Set ACLK to DCO
CSCTL2 |= SELA1 | SELA0;
CSCTL2 &= ~SELS2;                     // Set SMCLK to DCO
CSCTL2 |= SELS1 | SELS0;
CSCTL2 &= ~SELM2;                     // Set MCLK to DCO
CSCTL2 |= SELM1 | SELM0;
CSCTL3 &= ~DIVA2;                     // Divide ACLK by 8
CSCTL3 |= DIVA1 | DIVA0;

PJOUT |= BIT1;
do g_counter++;
while(g_counter != 25001);


/* 4. Configure pins 2.0 (TX) and 2.1 (RX) for UART. */
P2SEL0 &= ~(BIT1 | BIT0);
P2SEL1 &= ~BIT0;                     // RX won't work if TX P2SEL1 is on.
P2SEL1 |= BIT1;

PJOUT |= BIT2;
do g_counter--;
while(g_counter != 0);

/* 5. Configure UART settings. */
UCA0CTLW0 |= UCSWRST;                // Allow UART settings to be edited
UCA0CTLW0 &= ~UCPEN;                 // Disable parity bits
UCA0CTLW0 &= ~UCMSB;                 // Set data transfer to LSB first
UCA0CTLW0 &= ~UC7BIT;                // Set 8 bit data transfer
UCA0CTLW0 &= ~UCSPB;                 // Use 1 stop bit
UCA0CTLW0 &= ~(UCMODE1 | UCMODE0);   // set eUSCI_A to UART mode
UCA0CTLW0 &= ~UCSYNC;                // Set UART to asynchronous mode
UCA0CTLW0 &= ~UCSSEL1;               // Select the ACLK as the clock source
UCA0CTLW0 |= UCSSEL0;
UCA0CTLW0 &= ~UCRXEIE;               // Disable erroneous characters.
UCA0CTLW0 &= ~UCBRKIE;               // Disable break character interrupts
UCA0CTLW0 &= ~UCDORM;                // Allow all recieved characters to set UCRXIFG
UCA0CTLW0 &= ~UCTXADDR;              // Indicate the next frame to be data (not address)
UCA0CTLW0 &= ~UCTXBRK;               // Indicate the next frame transmitted is not a break
UCA0BRW = 0x0006;                    // Clock prescalar setting of baudrate generator
UCA0MCTLW = 0x0080;                  // First modulation select. Ignored if oversampling off
UCA0MCTLW |= 0x2000;                 // Second modulation select. Mod pattern for BITCLK
UCA0MCTLW |= UCOS16;                 // Enable oversampling
UCA0CTLW0 &= ~UCSWRST;               // Release for operation

PJOUT |= BIT3;
do g_counter++;
while(g_counter != 25001);

/* 6. Enable Rx and global interrupts. */
PJOUT &= ~(BIT3 | BIT2 | BIT1 | BIT0);
UCA0IE |= UCRXIE;
__bis_SR_register(GIE);

for(;;) {

/* 7. Enter LPM0 when not in ISR. LPM0 consists of

* CPU/MCLK disabled, ACLK active, SMCLK (optionally active),
* and DCO is enabled if sources either ACLK or SMCLK. */
__bis_SR_register(LPM0_bits);

}

return 0;

}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Sorry Brojangles, but your compiler isnt supported. Watcha know about mspgcc?
#endif
{

switch(__even_in_range(UCA0IV,0x08))
{

/* Vector 0: No interrupts */
case 0: break;

/* Vector 2: UCRXIFG - Receive buf is full */
case 2:

/* 1. Grab the data from Rx buffer. */
g_data = UCA0RXBUF;

/* 2. Four states corresponding to the received value. */
if(g_data == 0x55) {

PJOUT ^= BIT0;

} else if(g_data == 0x66) {

PJOUT ^= BIT1;

} else if(g_data == 0x77) {

PJOUT ^= BIT2;

} else {

PJOUT ^= BIT3;

}

/* 3. Clear the receive flag and exit. */
UCA0IFG &= ~UCRXIFG;
__bic_SR_register_on_exit(LPM0_bits);
break;

/* Vector 4: UCTXIFG - Transmit buf is empty*/
case 4: break;

/* Vector 6: USTTIFG - Start bit received */
case 6: break;

/* Vector 8: UCTXCPTIFG - Transmit complete */
case 8: break;
default:break;

}

}

tx.c

#include <msp430fr5739.h>
#include <stdint.h>

volatile uint16_t g_counter = 25000;
volatile uint8_t g_state = 0;

int main(void) {

/* 1. Disable the Watchdog timer. */
WDTCTL = WDTPW + WDTHOLD;

/* 2. Enable LED1-4 for output. */
PJDIR |= BIT3 + BIT2 + BIT1 + BIT0;
PJOUT &= ~(BIT3 + BIT2 + BIT1 + BIT0);

PJOUT |= BIT0;
do g_counter--;
while(g_counter != 0);

/* 3. Configure clock settings. */
CSCTL0_H = 0xA5;                      // Write CSKEY password to configure clock settings
CSCTL1 &= ~DCORSEL;                   // Set DCO to 8MHz
CSCTL1 |= DCOFSEL1 | DCOFSEL0;
__delay_cycles(4);                    // Allow the DCO to settle at 8MHz
CSCTL2 &= ~SELA2;                     // Set ACLK to DCO
CSCTL2 |= SELA1 | SELA0;
CSCTL2 &= ~SELS2;                     // Set SMCLK to DCO
CSCTL2 |= SELS1 | SELS0;
CSCTL2 &= ~SELM2;                     // Set MCLK to DCO
CSCTL2 |= SELM1 | SELM0;
CSCTL3 &= ~DIVA2;                     // Divide ACLK by 8
CSCTL3 |= DIVA1 | DIVA0;

PJOUT |= BIT1;
do g_counter++;
while(g_counter != 25001);


/* 4. Configure pins 2.0 (TX) and 2.1 (RX) for UART. */
P2SEL0 &= ~(BIT1 | BIT0);
P2SEL1 |= BIT1 | BIT0;

PJOUT |= BIT2;
do g_counter--;
while(g_counter != 0);

/* 5. Configure UART settings. */
UCA0CTLW0 |= UCSWRST;                 // Allow UART settings to be edited
UCA0CTLW0 &= ~UCPEN;                  // Disable parity bits
UCA0CTLW0 &= ~UCMSB;                  // Set data transfer to LSB first
UCA0CTLW0 &= ~UC7BIT;                 // Set 8 bit data transfer
UCA0CTLW0 &= ~UCSPB;                  // Use 1 stop bit
UCA0CTLW0 &= ~(UCMODE1 | UCMODE0);    // set eUSCI_A to UART mode
UCA0CTLW0 &= ~UCSYNC;                 // Set UART to asynchronous mode
UCA0CTLW0 &= ~UCSSEL1;                // Select the ACLK as the clock source
UCA0CTLW0 |= UCSSEL0; 
UCA0CTLW0 &= ~UCRXEIE;                // Disable erroneous characters.
UCA0CTLW0 &= ~UCBRKIE;                // Disable break character interrupts
UCA0CTLW0 &= ~UCDORM;                 // Allow all recieved characters to set UCRXIFG
UCA0CTLW0 &= ~UCTXADDR;               // Indicate the next frame to be data (not address)
UCA0CTLW0 &= ~UCTXBRK;                // Indicate the next frame transmitted is not a break
UCA0BRW = 0x0006;                     // Clock prescalar setting of baudrate generator
UCA0MCTLW = 0x0080;                   // First modulation select. Ignored if oversampling off
UCA0MCTLW |= 0x2000;                  // Second modulation slelect. Mod pattern for BITCLK
UCA0MCTLW |= UCOS16;                  // Enable oversampling
UCA0CTLW0 &= ~UCSWRST;                // Release for operation

PJOUT |= BIT3;
do g_counter++;
while(g_counter != 25001);

/* 6. Enable Tx and global interrupts. */
PJOUT &= ~(BIT3 | BIT2 | BIT1 | BIT0);
UCA0IE |= UCTXIE;
__bis_SR_register(GIE);

for(;;) {

/* 7. Enter LPM0 when not in ISR. LPM0 consists of
* CPU/MCLK disabled, ACLK active, SMCLK (optionally active),
* and DCO is enabled if sources either ACLK or SMCLK. */
__bis_SR_register(LPM0_bits);
}

return 0;

}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Sorry Brojangles, but your compiler isnt supported. Whatcha know about mspgcc?
#endif
{

switch(__even_in_range(UCA0IV,0x08))
{

/* Vector 0: No interrupts */
case 0: break;

/* Vecotr 2: UCRXIFG - Receive buf is full */
case 2: break;

/* Vector 4: UCTXIFG - Transmit buf is empty */
case 4:

/* 1. Wait for a sec then flash LED. */
g_counter = 25000;
do g_counter--;
while(g_counter != 0);
PJOUT ^= BIT0;

/* 2. Four states corresponding to different transmit vals. */
if(g_state == 0) {

UCA0TXBUF = 0x55;
g_state = 1;

} else if(g_state == 1) {

UCA0TXBUF = 0x66;
g_state = 2;

} else if(g_state == 2) {

UCA0TXBUF = 0x77;
g_state = 3;

} else {

UCA0TXBUF = 0x88;
g_state = 0;

}

/* 3. Clear the transmit flag and then exit. */
UCA0IFG &= ~UCTXIFG;
__bic_SR_register_on_exit(LPM0_bits);
break;

/* Vector 6: USTTIFG - Start bit received */
case 6: break;

/* Vector 8: UCTXCPTIFG - Transmit complete */
case 8: break;
default:break;

}

}

  • Hey Taylor,

    BIT0 and BIT1 are set in P2SEL1 and cleared in P2SEL0 for UART mode, simple as that.  Attached is a code example from the MSP430FR57xx_Code_Examples package:

    MSP430FR57xx_uscia0_uart_04.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, 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--*/
    //******************************************************************************
    //  MSP430FR57xx Demo - USCI_A0 External Loopback test
    //
    //  Description: This demo connects TX to RX of the MSP430 UART 
    //  The example code shows proper initialization of registers 
    //  and interrupts to receive and transmit data.
    //  ACLK = BRCLK = XT1 = 32.768Khz, MCLK = SMCLK = default DCO = ~1MHz
    //
    //                                
    //                MSP430FR5739 
    //                       
    //             -----------------   
    //       RST -|     P2.0/UCA0TXD|----|
    //       |----|XIN              |    |
    //      32kHz-|                 |    |
    //       |----|XOUT P2.1/UCA0RXD|----|
    //            |                 |  
    //
    //   F.  Chen
    //   Texas Instruments Inc.
    //   November 2012
    //   Built with CCS V5.2.1 and IAR Embedded Workbench Version: 5.51.1
    //******************************************************************************
    #include <msp430.h>
    
    unsigned int i;
    unsigned char RXData = 0;
    unsigned char TXData = 0;
    unsigned char check = 0;
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // stop watchdog
     
      // XT1 Setup 
      
      PJSEL0 |= BIT4 + BIT5; 
      
      CSCTL0_H = 0xA5;
      CSCTL1 |= DCOFSEL0 + DCOFSEL1;             // Set max. DCO setting
      CSCTL2 = SELA_0 + SELS_3 + SELM_3;        // set ACLK = XT1; MCLK = DCO
      CSCTL3 = DIVA_0 + DIVS_3 + DIVM_3;        // set all dividers 
      CSCTL4 |= XT1DRIVE_0; 
      CSCTL4 &= ~XT1OFF;
      
      do
      {
        CSCTL5 &= ~XT1OFFG;
                                                // Clear XT1 fault flag
        SFRIFG1 &= ~OFIFG; 
      }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag
      
      // Configure UART pins
      P2SEL1 |= BIT0 + BIT1;
      P2SEL0 &= ~(BIT0 + BIT1);
      // Configure UART 0
      UCA0CTL1 |= UCSWRST; 
      UCA0CTL1 = UCSSEL_1;                      // Set ACLK = 32768 as UCBRCLK
      UCA0BR0 = 3;                              // 9600 baud
      UCA0MCTLW |= 0x5300;                      // 32768/9600 - INT(32768/9600)=0.41
                                                // UCBRSx value = 0x53 (See UG)  
      UCA0BR1 = 0;            
      UCA0CTL1 &= ~UCSWRST;                     // release from reset
      UCA0IE |= UCRXIE;                         // enable RX interrupt
      
      __enable_interrupt();                     // Enable interrupt
      while (1)
      {
        TXData = TXData+1;                      // Increment TX data
        UCA0TXBUF = TXData;                     // Load data onto buffer
        while(check !=1 );
        check = 0;  
      }
    }
    
    
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = USCI_A0_VECTOR             // USCI ISR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      UCA0IFG &=~ UCRXIFG;                      // Clear interrupt
      RXData = UCA0RXBUF;                       // Clear buffer
      if(!(RXData == TXData))                   // Check value
      {
        while(1);
      }
      check =1;
      
    } 
    

    Let's start with this external loopback code, which is intended to simply send a byte and receive it back before incrementing the byte's value and starting all over again.  Load this code onto both MSP-EXP430FR5739 but add the following lines right after the __enable_interrupt(); command:

    while(check !=1 );

    check = 0;

    This will require one of the boards to wait for a reception before transmitting its first byte. Now connect the TX line of the first board to the RX line of the second and vice versa and run this modified code board followed by the original code board.  You should see both boards sending and receiving bytes.  You can modify the code from here to fit your application.

    Note that a 32 kHz crystal is required to be placed on XT1 for this code example.  I also like the error message for the USCI_A0_ISR.

    Regards,

    Ryan

  • Thank you for the reply! I ran your code, and it still wasn't quite working right, but I finally figured out that I had the Tx/Rx jumpers (going from the emulation side to FR57xx) oriented the wrong way. Initially I was trying to get back channel UART to work (to communicate between my mac and board), and I read online that you needed to rotate the jumpers. However, after back channel UART didn't work, I decided to see if i could even get board to board communication working, but never considered returning the jumpers to their original position. Do by chance know how to set up back channel UART? It would be great if I could send data from my board to my computer. Currently I've been trying to send data to my computer and read the serial port using a python script, but i haven't been having any luck. 

  • Taylor,

    Code example MSP430FR57xx_uscia0_uart_03.c (attached) is great for testing your backchannel UART communication as it demonstrates an echo of a character sent by the PC.  This can be tested with a software program such as Tera Term or HyperTerminal using a baud rate of 9600 and connection to the MSP-EXP430FR5739's Application UART COM port.  Once again, this example uses ACLK so you need to make sure that a 32 kHz crystal is connected to the XT1 pins or change the USCI clock source and baud rate prescaler registers accordingly.  As noted before it is also important that the Tx/Rx jumpers are oriented vertically on the board for backchannel UART communication.

    MSP430FR57xx_uscia0_uart_03.c
    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, 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--*/
    //******************************************************************************
    //  MSP430FR57xx Demo - USCI_A0 UART echo at 9600 baud
    //
    //  Description: This demo echoes back characters received via a PC serial portt.
    //  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.
    //  ACLK = n/a, MCLK = SMCLK = BRCLK = default DCO = ~1MHz
    //
    //                                
    //                MSP430FR5739 
    //                       
    //             -----------------   
    //       RST -|     P2.0/UCA0TXD|----> PC (echo)
    //            |                 |    
    //           -|                 |    
    //            |     P2.1/UCA0RXD|<---- PC
    //            |                 |  
    //
    //   P. Thanigai
    //   Texas Instruments Inc.
    //   August 2010
    //   Built with CCS V4 and IAR Embedded Workbench Version: 5.10
    //******************************************************************************
    #include <msp430.h>
    
    unsigned int i;
    unsigned char RXData = 0;
    unsigned char TXData = 0;
    unsigned char check = 0;
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // stop watchdog
     
      // XT1 Setup 
      
      PJSEL0 |= BIT4 + BIT5; 
      
      CSCTL0_H = 0xA5;
      CSCTL1 |= DCOFSEL0 + DCOFSEL1;             // Set max. DCO setting
      CSCTL2 = SELA_0 + SELS_3 + SELM_3;        // set ACLK = XT1; MCLK = DCO
      CSCTL3 = DIVA_0 + DIVS_3 + DIVM_3;        // set all dividers 
      CSCTL4 |= XT1DRIVE_0; 
      CSCTL4 &= ~XT1OFF;
      
      do
      {
        CSCTL5 &= ~XT1OFFG;
                                                // Clear XT1 fault flag
        SFRIFG1 &= ~OFIFG; 
      }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag
      
      // Configure UART pins
      P2SEL1 |= BIT0 + BIT1;
      P2SEL0 &= ~(BIT0 + BIT1);
      // Configure UART 0
      UCA0CTL1 |= UCSWRST; 
      UCA0CTL1 = UCSSEL_1;                      // Set ACLK = 32768 as UCBRCLK
      UCA0BR0 = 3;                              // 9600 baud
      UCA0BR1 = 0; 
      UCA0MCTLW |= 0x5300;                      // 32768/9600 - INT(32768/9600)=0.41
                                                // UCBRSx value = 0x53 (See UG)
      UCA0CTL1 &= ~UCSWRST;                     // release from reset
      UCA0IE |= UCRXIE;                         // Enable RX interrupt
      
       __bis_SR_register(LPM0_bits + GIE);      // LPM3 + Enable interrupt
    }
    
    
    // Echo back RXed character, confirm TX buffer is ready first
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      switch(__even_in_range(UCA0IV,0x08))
      {
      case 0:break;                             // Vector 0 - no interrupt
      case 2:                                   // Vector 2 - RXIFG
        while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
        UCA0TXBUF = UCA0RXBUF;                  // TX -> RXed character
        break;
      case 4:break;                             // Vector 4 - TXIFG
      default: break;  
      }
    }
    

    Regards,

    Ryan

  • Worked like a charm. Thank you again! Is there a link you can give me to download all of those MSP430FR57xx code examples? I remember running across it a long time ago, but have not been able to locate it since.

  • www.ti.com/.../slac491

    Under the "Tools & software" tab of the MSP430FR5739 product page: www.ti.com/.../MSP430FR5739

    Regards,
    Ryan

**Attention** This is a public forum