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.

CCS/MSP430FR6047: Not receiving output while testing UART example code

Part Number: MSP430FR6047
Other Parts Discussed in Thread: EVM430-FR6047

Tool/software: Code Composer Studio

Hi,

I am new to MSP430 and I am trying to learn how UART code works with the help of example code given by ti.

The example description tells me that the UART will recieve from the Serial port of PC and echo it back. I am using the Serial terminal present in the CCS and set the baud rate to 9600. But I am not able to recieve any Output.Am i missing something on EVM module ?or What is the right way to test the above Code?

Best Regards,

Divya H

  • Hi Divya,

    What hardware do you use?

    Regards,
    Ling
  • Hi Ling,

    I am currently using EVM430-FR6047 module.

    Is there any particular procedure that m missing to test the above Code?

    Regards,

    Divya H

  • Hi Divya,

    Really sorry for the late reply.

    If you want to use uart to send data to PC by on board ez-FET. Please use eUSCI_A1 which located in P1.2 and P1.3

    Regards,
    Ling
  • Hi Ling,

    It would be a great help if you could tell me how to configure P1.2 and P1.3 as Tx and Rx for uart transmission.

    I didn't get a clear idea as to how to configure the ports from the example code.

    Regards,

    Divya

  • #include <msp430.h>
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop Watchdog
    
        // Configure GPIO
        P1SEL0 |= BIT2 | BIT3;                  // USCI_A1 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_A0 for UART mode
        UCA1CTLW0 = UCSWRST;                    // Put eUSCI in reset
        UCA1CTLW0 |= UCSSEL__SMCLK;             // CLK = SMCLK
        // Baud Rate calculation
        // 8000000/(16*9600) = 52.083
        // Fractional portion = 0.083
        // User's Guide Table 24-4: UCBRSx = 0x04
        // UCBRFx = int ( (52.083-52)*16) = 1
        UCA1BRW = 52;                           // 8000000/16/9600
        UCA1MCTLW |= UCOS16 | UCBRF_1 | 0x4900;
        UCA1CTLW0 &= ~UCSWRST;                  // Initialize eUSCI
        UCA1IE |= UCRXIE;                       // Enable USCI_A0 RX interrupt
    
        __bis_SR_register(LPM3_bits + GIE);     // Enter LPM3, interrupts enabled
        __no_operation();                       // For debugger
    }
    
    unsigned char temp;
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=EUSCI_A1_VECTOR
    __interrupt void USCI_A1_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(EUSCI_A1_VECTOR))) USCI_A1_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
        switch(__even_in_range(UCA1IV, USCI_UART_UCTXCPTIFG))
        {
            case USCI_NONE: break;
            case USCI_UART_UCRXIFG:
                while(!(UCA1IFG&UCTXIFG));
                temp = UCA1RXBUF;
                UCA1TXBUF = temp;
                UCA1TXBUF = temp;
                __no_operation();
                break;
            case USCI_UART_UCTXIFG: break;
            case USCI_UART_UCSTTIFG: break;
            case USCI_UART_UCTXCPTIFG: break;
            default: break;
        }
    }
    

  • Hi Ling,

    Thank you for your prompt reply!
    I believe the code is for UART to recieve data from the Serial port of PC and echo it back.
    What change must i do if i have to transmit data using uart to PC?

    Regards,
    Divya H
  • Hi Divya,

    UCA1TXBUF = xxx;

    Regards,

    Ling

**Attention** This is a public forum