MSP430FR2111: Please tell me how to communicate serially using UART.

Part Number: MSP430FR2111


Thank you to everyone at the E2E Forum for your help.

I'm currently developing a system that uses the Texas Instruments MSP430FR2111 MCU.

The system sends measured values ​​to an external PC about once a day, using UART as the communication method.

I created source code for port initialization and data transmission, and am attempting to receive data using a PC terminal application via the FT232RL, but for some reason, when P1.6 (Rxd) is connected to the FT232RL's Txd, data cannot be sent from P1.7 (Txd).

I'm plagued by this mysterious phenomenon: if I disconnect the wire connecting P1.6 (Rxd) to the FT232RL's Txd, data can be sent from P1.7 (Txd).

I have multiple FT232RLs, so I tried several, but I got the same result with each.
I am attaching the current source code, and although I apologize for bothering you during your busy schedule, I would appreciate it if you could tell me how to solve the problem.
Thank you in advance.

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

#pragma DATA_SECTION(accumulated_distance, ".myFRAM")
volatile uint32_t accumulated_distance;

#pragma DATA_SECTION(magic_flag, ".myFRAM")
volatile uint32_t magic_flag;

#define MAGIC_INITIALIZED   0xFFFFFFF0      // 2025.12.03
#define SMCLK_FREQ_HZ       1000000UL       // 2025.12.09
#define UART_BRW_VALUE      104
#define UART_MCTLW_VALUE    (UCOS16 | (2 << 4) | (0 << 8))

volatile uint8_t inc_flag = 0;

__interrupt void Port_1(void);

void uart_putc(char c);
void uart_puts(const char *s);

#define MCLK_FREQ_MHZ 1                     // MCLK = 1MHz

int main(void) {
    WDTCTL = WDTPW | WDTHOLD;               // Stop watchdog timer
    SYSCFG0 = FRWPPW;                       // 

    __bis_SR_register(SCG0);                // Disable FLL
    CSCTL3 = SELREF__REFOCLK;               // Set REFO as FLL reference source
    CSCTL1 = DCOFTRIMEN_0 | DCORSEL_0;      // DCO Range = 1MHz
    CSCTL2 = FLLD_0 + 30;                   // DCODIV = 1MHz
    __delay_cycles(3);
    __bic_SR_register(SCG0);                // Enable FLL
    CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
                                               // default DCODIV as MCLK and SMCLK source

    //
    // P1.0 / A0
    P1SEL0 |= BIT0; P1SEL1 |= BIT0;

    // P1.1 / A1
    P1DIR |= BIT1;

    // P1.3 / A3
    P1SEL0 &= ~BIT3; P1SEL1 &= ~BIT3;   //
    P1DIR &= ~BIT3;                     //
    P1IES |= BIT3;                      //
    P1IFG &= ~BIT3;                     //
    P1IE |= BIT3;                       //

    // P1.4 / A4
    P1SEL0 &= ~BIT4; P1SEL1 &= ~BIT4;   //
    P1DIR |= BIT4;                      //
    P1OUT &= ~BIT4;                     //

    // P1.5 / A5
    P1SEL0 &= ~BIT5; P1SEL1 &= ~BIT5;   //
    P1DIR |= BIT5;                      //
    P1OUT &= ~BIT5;                     //

    // P2.0
    P2SEL0 &= ~BIT0; P2SEL1 &= ~BIT0;   //
    P2DIR  |= BIT0;                     //
    P2OUT  |= BIT0;                     //

    // P2.1
    P2SEL0 &= ~BIT1; P2SEL1 &= ~BIT1;   //
    P2DIR &= ~BIT1;                     //

    // UART
    // P1.6 = UCA0RXD, P1.7 = UCA0TXD
    // 1) stop eUSCI_A
    
    //----------------------------------------------------------
    // (1) RXD (P1.6)
    //----------------------------------------------------------
    P1DIR &= ~BIT6;      // RXD input
    P1OUT |= BIT6;       // pull-up
    P1REN |= BIT6;       // enable pull-up

    //
    __delay_cycles(200000);   // 200ms @1MHz

    //----------------------------------------------------------
    // (2) Function change
    //----------------------------------------------------------
    P1REN &= ~BIT6;            //
    P1SEL0 |=  BIT6 | BIT7;    //
    P1SEL1 &= ~(BIT6 | BIT7);

    //----------------------------------------------------------
    // (3) DIR
    //----------------------------------------------------------
    P1DIR &= ~BIT6;     //
    P1DIR |=  BIT7;     //

    //----------------------------------------------------------
    // (4)
    //----------------------------------------------------------
    UCA0CTLW0  =  UCSWRST;        //
    UCA0CTLW0 |=  UCSSEL__SMCLK;  // SMCLK = 1MHz

    // 9600bps @ 1MHz
    UCA0BR0 = 104;
    UCA0BR1 = 0;
    UCA0MCTLW = 0;                //

    UCA0CTLW0 &= ~UCSWRST;        // UART start

    // UCA0IE |= UCRXIE;                //

    // ADC
    ADCCTL0 &= ~ADCENC;                 //
    ADCCTL1 |= ADCSHP | ADCSSEL_2;      //
    ADCCTL2 |= ADCRES_2;                //

    ADCMCTL0 |= ADCINCH_0;              //

    ADCCTL0 |= ADCON;                   //
    ADCIE |= ADCIE0;                    //
    
    PM5CTL0 &= ~LOCKLPM5;                   // Disable the GPIO power-on default high-impedance mode
                                            // to activate previously configured port settings

    // Check if this is first-ever run
    if (magic_flag != MAGIC_INITIALIZED){
        accumulated_distance = 0;           // Initialize on first run only
        magic_flag = MAGIC_INITIALIZED;
    }

    __delay_cycles(500000);

// Example
    uart_puts("U");

    while(1)							//
    {
        __low_power_mode_3();           //
        //
        if (inc_flag){
            accumulated_distance++;
            inc_flag = 0;
        }
    }
}

void uart_putc(char c) {
    while (! (UCA0IFG & UCTXIFG));      //
    UCA0TXBUF = c;                      // send
}

void uart_puts(const char *s){
    while (*s){
        uart_putc(*s++);
    }
}

// Port 1.x interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{    
   if (P1IFG & BIT3){                   //
        inc_flag = 1;                   //
        P1IFG &= ~BIT3;                 //
        __bic_SR_register_on_exit(LPM3_bits);
    }
}
  • Hi Takashi,

    Because you observe that UART works when the FT232RL is not connected, this seems like a hardware issue.

    I would first check to see if there is a shared ground between the MSP430FR2111 and FT232RL. Also ensure that there isn't a voltage level mismatch. Are you certain you are not confusing the TX and RX pins for the FT232RL? Have you tried probing the connection?

    Best,

    Owen

  • Dear Owen

    Thank you for your reply.
    It seems I expressed it poorly. Let me explain again.
    The MSP430FR2111 and FT232RL are connected with three wires.
    From the MSP430FR2111's perspective, these are GND, TXD, and RXD.
    This does not mean that they are not connected.

    When these three wires are connected and I send data, the sent data does not appear in the PC's terminal app.
    However, if I disconnect the RXD wire and connect only the GND and TXD wires, the sent data does appear in the terminal app.

    It seems that the data transmission is being hindered by the RXD wire being connected.
    What do you think? Did I explain the situation?

    When I sent the character 'U', the width of 1 bit was approximately 104 μs. I think the numbers are correct.

    For proper communication, the three lines GND, TXD, and RXD must be connected, so the current connection is incomplete.

    Immediately before sending data, I make the determination using
    while (!(UCA0IFG & UCTXIFG)) ;
    This code makes the determination, but I'm skeptical of whether this determination is correct in the first place.

    I apologize for the trouble. I would appreciate your advice.

  • Hi Takashi,

    I understand now, thanks for the clarification.

    I looked closer at your code and I believe the issue may be with how you are configuring the pins.

    This is your current code:

    // UART
        // P1.6 = UCA0RXD, P1.7 = UCA0TXD
        // 1) stop eUSCI_A
        
        //----------------------------------------------------------
        // (1) RXD (P1.6)
        //----------------------------------------------------------
        P1DIR &= ~BIT6;      // RXD input
        P1OUT |= BIT6;       // pull-up
        P1REN |= BIT6;       // enable pull-up
    
        //
        __delay_cycles(200000);   // 200ms @1MHz
    
        //----------------------------------------------------------
        // (2) Function change
        //----------------------------------------------------------
        P1REN &= ~BIT6;            //
        P1SEL0 |=  BIT6 | BIT7;    //
        P1SEL1 &= ~(BIT6 | BIT7);
    
        //----------------------------------------------------------
        // (3) DIR
        //----------------------------------------------------------
        P1DIR &= ~BIT6;     //
        P1DIR |=  BIT7;     //
    
        //----------------------------------------------------------
        // (4)
        //----------------------------------------------------------
        UCA0CTLW0  =  UCSWRST;        //
        UCA0CTLW0 |=  UCSSEL__SMCLK;  // SMCLK = 1MHz
    
        // 9600bps @ 1MHz
        UCA0BR0 = 104;
        UCA0BR1 = 0;
        UCA0MCTLW = 0;                //
    
        UCA0CTLW0 &= ~UCSWRST;        // UART start
    
        // UCA0IE |= UCRXIE;                //

    From an SDK example (msp430fr211x_euscia0_uart_01):

    // Configure UART pins
      P1SEL0 |= BIT6 | BIT7;                    // set 2-UART pin as second function
    
      // Configure UART
      UCA0CTLW0 |= UCSWRST;
      UCA0CTLW0 |= UCSSEL__SMCLK;
    
      // Baud Rate calculation
      // 8000000/(16*9600) = 52.083
      // Fractional portion = 0.083
      // User's Guide Table 17-4: UCBRSx = 0x49
      // UCBRFx = int ( (52.083-52)*16) = 1
      UCA0BR0 = 52;                             // 8000000/16/9600
      UCA0BR1 = 0x00;
      UCA0MCTLW = 0x4900 | UCOS16 | UCBRF_1;
    
      UCA0CTLW0 &= ~UCSWRST;                    // Initialize eUSCI
      UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
    

    Configuring the pin direction is not necessary. In this SDK example, before UART is configured, all GPIO on port 1 are configured to be outputs and enables pull-downs.

    This is likely the reason why UART doesn't work when you connect to the FT232RL. The MSP430 RXD pin configuration may be interfering with the communication.

    I would suggest leveraging the msp430fr211x_euscia0_uart_01 and any other MSP430 SDK examples.

    Best,

    Owen

  • Dear Owen Li

    Thank you for your programming advice.
    I'm currently suffering from influenza A, so I'm only able to test the program you taught me today.

    I tried it, but the problem is still the same.
    I can send characters when connecting two wires, Txd and GND,
    but I can't send characters when connecting three wires, Txd, Rxd, and GND.

    I have no idea what the problem is.
    What should I do?

  • Hi Takashi,

    I still believe this is a hardware issue, and not with the MSP430.

    The fact that this issue only happens when you connect the RXD pin makes me want to believe that there is potentially a ground loop between the USB ground and MSP430 ground, excess current draw, or a voltage difference between the ground references.

    I am not familiar with the FT232RL, but can verify what the output voltage and current of the TXD pin is? It is possible that the output is too strong and is injecting current into the MSP430 RXD pin.

    Best,

    Owen

  • Hi Owen,

    I am writing to share that the UART communication issue has been successfully resolved! Thank you very much for your insightful advice.

    The root cause turned out to be a combination of the initialization sequence and a hardware power-sequencing issue (back-powering).

    Key Findings:

    GPIO Initialization: As you suggested, properly setting P1SEL0/1 and ensuring a clean transition was crucial.

    Power-On Reset (POR) Failure: We found that the FT232RL (powered by the USB/Tablet) was outputting 3.3V to the MSP430's RXD pin before the MSP430 itself was powered on. This caused the MSP430 to fail its Power-On Reset (POR) due to back-powering through the ESD protection diodes.

    Stabilization Delay: Adding a ~150ms delay after configuring the GPIO pins but before releasing the eUSCI software reset (UCSWRST) significantly improved reliability.

    Final Solution:

    Hardware: Connected the FT232RL's VCCIO pin to the MSP430's VCC to ensure the logic levels and power states are synchronized.

    Software: Applied the correct 1MHz baud rate settings and the stabilization delay as we discussed.

    The system is now transmitting data perfectly. Your guidance helped me narrow down the focus and finally pinpoint the electrical cause.

    I truly appreciate your professional support!

    Best regards,

    --------------------------

    Takashi Yumita

  • Hi Takashi,

    I am glad to hear that you were able to find a solution to this issue. If you need any further support, please feel free to open a new thread.

    Best,

    Owen

**Attention** This is a public forum