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.

MSP430FR4133: UART - echo example doesn't work

Part Number: MSP430FR4133
Other Parts Discussed in Thread: MSP-EXP430FR5994

I am using MSPEXP430FR4133 LaunchPad. I am trying to run "msp430fr413x_euscia0_uart_01.c" on my device. I am using Putty (Serial, ACM1), to see functioning of UART backchannel, but I receive no response. I have checked that transmitter works properly. But if i send some data to Launchpad from PC, the interrupt isn't invoked.

My code:

#include <msp430.h>

void Init_GPIO();

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

    // Configure GPIO
    Init_GPIO();
    PM5CTL0 &= ~LOCKLPM5;                    // Disable the GPIO power-on default high-impedance mode
                                           // to activate 1previously configured port settings

    __bis_SR_register(SCG0);                 // disable FLL
    CSCTL3 |= SELREF__REFOCLK;               // Set REFO as FLL reference source
    CSCTL0 = 0;                              // clear DCO and MOD registers
    CSCTL1 &= ~(DCORSEL_7);                  // Clear DCO frequency select bits first
    CSCTL1 |= DCORSEL_3;                     // Set DCO = 8MHz
    CSCTL2 = FLLD_0 + 243;                   // DCODIV = 8MHz
    __delay_cycles(3);
    __bic_SR_register(SCG0);                 // enable FLL
    while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // Poll until FLL is locked

    CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
                                           // default DCODIV as MCLK and SMCLK source

    // Configure UART pins
    P1SEL0 |= BIT0 | BIT1;                    // 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 14-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

    __bis_SR_register(LPM3_bits|GIE);         // Enter LPM3, interrupts enabled
}

#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void) {
    switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG)) {
        case USCI_NONE: break;
        case USCI_UART_UCRXIFG:
            while(!(UCA0IFG&UCTXIFG));
            UCA0TXBUF = UCA0RXBUF;
            break;
        case USCI_UART_UCTXIFG: break;
        case USCI_UART_UCSTTIFG: break;
        case USCI_UART_UCTXCPTIFG: break;
        default: break;
    }
}

void Init_GPIO() {
    P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; P4DIR = 0xFF;
    P5DIR = 0xFF; P6DIR = 0xFF; P7DIR = 0xFF; P8DIR = 0xFF;
    P1REN = 0xFF; P2REN = 0xFF; P3REN = 0xFF; P4REN = 0xFF;
    P5REN = 0xFF; P6REN = 0xFF; P7REN = 0xFF; P8REN = 0xFF;
    P1OUT = 0x00; P2OUT = 0x00; P3OUT = 0x00; P4OUT = 0x00;
    P5OUT = 0x00; P6OUT = 0x00; P7OUT = 0x00; P8OUT = 0x00;
}
#include <msp430.h>

void Init_GPIO();

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

    // Configure GPIO
    Init_GPIO();
    PM5CTL0 &= ~LOCKLPM5;                    // Disable the GPIO power-on default high-impedance mode
                                           // to activate 1previously configured port settings

    __bis_SR_register(SCG0);                 // disable FLL
    CSCTL3 |= SELREF__REFOCLK;               // Set REFO as FLL reference source
    CSCTL0 = 0;                              // clear DCO and MOD registers
    CSCTL1 &= ~(DCORSEL_7);                  // Clear DCO frequency select bits first
    CSCTL1 |= DCORSEL_3;                     // Set DCO = 8MHz
    CSCTL2 = FLLD_0 + 243;                   // DCODIV = 8MHz
    __delay_cycles(3);
    __bic_SR_register(SCG0);                 // enable FLL
    while(CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // Poll until FLL is locked

    CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
                                           // default DCODIV as MCLK and SMCLK source

    // Configure UART pins
    P1SEL0 |= BIT0 | BIT1;                    // 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 14-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

    __bis_SR_register(LPM3_bits|GIE);         // Enter LPM3, interrupts enabled
}

#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void) {
    switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG)) {
        case USCI_NONE: break;
        case USCI_UART_UCRXIFG:
            while(!(UCA0IFG&UCTXIFG));
            UCA0TXBUF = UCA0RXBUF;
            break;
        case USCI_UART_UCTXIFG: break;
        case USCI_UART_UCSTTIFG: break;
        case USCI_UART_UCTXCPTIFG: break;
        default: break;
    }
}

void Init_GPIO() {
    P1DIR = 0xFF; P2DIR = 0xFF; P3DIR = 0xFF; P4DIR = 0xFF;
    P5DIR = 0xFF; P6DIR = 0xFF; P7DIR = 0xFF; P8DIR = 0xFF;
    P1REN = 0xFF; P2REN = 0xFF; P3REN = 0xFF; P4REN = 0xFF;
    P5REN = 0xFF; P6REN = 0xFF; P7REN = 0xFF; P8REN = 0xFF;
    P1OUT = 0x00; P2OUT = 0x00; P3OUT = 0x00; P4OUT = 0x00;
    P5OUT = 0x00; P6OUT = 0x00; P7OUT = 0x00; P8OUT = 0x00;
}

  • Are you using GCC or the TI compiler? ("Show Build Settings->CCS General->Compiler Version")

    Also, make sure the TXD/RXD jumpers are installed on J101 (the "bridge" header), and the P1.0 jumper is removed from JP1 (down at the bottom).

  • Thanks for quick reply. I am using TI compiler. J101 both TXD and RXD are installed. I removed the P1.0 jumper from JP1, which turned off LED on P1.0. But the example still doesn't work. When i use debugger it seems that interrupt isn't even invoked.

  • When I run your code on my Launchpad, I get echoes with PuTTY and Windows, with or without the debugger.

    When I run with the debugger, the echoes are "stuttery" due to the USB/UART/debugger contention.

    One difference here is Linux, but I don't have a Linux system here to try it on.

    Is PuTTY's "Flow Control" set to "None"? I forget that sometimes, and then the UART randomly freezes.

    Are the RXD/TXD jumpers on J101 parallel to the other jumpers? (A few weeks ago there was someone who had been using a G2 Launchpad, and assumed the "rotation" thing was true for all Launchpads, so I thought I'd ask.)

    [Edit: Minor wording fix.]

  • I experience a similar issue with CCS10.

    The example eusci_a_uart_ex1_loopbackAdvanced.c from the driverlibs works fine on a Launchpad MSP-EXP430FR5994 when flashed with CCS9.3.0.00012 and eighther TI v18.12.6LTS and v20.2.2.LTS compiler.

    For CCS10.1.0.00010 it does not work with any compiler. It seems like the interrupt is not triggered.

    What toolchain-changes could cause this behaviour in CCS10?

  • My issue was adressed and resolved here:

    CCS/MSP430FR59941: UART Interrupt not triggered on MSP430FR5994(1) when Code is flashed with CCS10 -...

    e2e.ti.com
    Part Number: MSP430FR59941 Other Parts Discussed in Thread: MSP-EXP430FR5994 , MSP430FR5994 , MSP430WARE , , MSP430FR2111 , MSP430FR5964 Tool/software: Code Composer

    There were missing port configuration defines in the mcu definitions header file.

**Attention** This is a public forum