MSP-EXP430FR5969: Uart configuration

Part Number: MSP-EXP430FR5969
Other Parts Discussed in Thread: MSP430FR5969, MSP430WARE

Dear Team,

I am  MSP430FR5969 Lanchpad dev kit ,
I am building a application where,  P2.5(pin20) and P2.6(Pin21) should act as uart (UCA1TXD, UCA1RXD), and it should be able to send and receive data from host PC, but with the MSP430Ware sdk there is only application supported for P2.0/UCA0TXD and P2.1/UCA0RXD uart, how to configure uart for UCA1.

Regards,
Nikhil K

  • You can show your code, but usually it is as easy as changing all the "0"'s to "1"'s. In the name.

  • Hi Keith,

    I did same and connected 3v3 TTL cable on TXD and RXD (20 pin boosterpack plugin module). but i dont see anything on debug terminal, not able to provide any input

    Do you have any reference application for this

    /* --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--*/
    //******************************************************************************
    //  MSP430FR59xx Demo - eUSCI_A0 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
    //
    //                MSP430FR5969
    //             -----------------
    //       RST -|     P2.5/UCA1TXD|----> PC (echo)
    //            |                 |
    //            |                 |
    //            |     P2.6/UCA1RXD|<---- PC
    //            |                 |
    //
    //   P. Thanigai
    //   Texas Instruments Inc.
    //   August 2012
    //   Built with IAR Embedded Workbench V5.40 & Code Composer Studio V5.5
    //******************************************************************************
    #include "msp430.h"
    
    int main(void)
    {
      WDTCTL = WDTPW | WDTHOLD;                 // Stop Watchdog
    
      // Configure GPIO
      P2SEL1 |= BIT0 | BIT1;                    // USCI_A1 UART operation
      P2SEL0 &= ~(BIT0 | BIT1);
    
      // 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 >> 8;                    // Unlock clock 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_A1 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 21-4: UCBRSx = 0x04
      // UCBRFx = int ( (52.083-52)*16) = 1
      UCA1BR0 = 52;                             // 8000000/16/9600
      UCA1BR1 = 0x00;
      UCA1MCTLW |= UCOS16 | UCBRF_1;
      UCA1CTLW0 &= ~UCSWRST;                    // Initialize eUSCI
      UCA1IE |= UCRXIE;                         // Enable USCI_A1 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=USCI_A1_VECTOR
    __interrupt void USCI_A1_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_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));
          UCA1TXBUF = UCA1RXBUF;
          __no_operation();
          break;
        case USCI_UART_UCTXIFG: break;
        case USCI_UART_UCSTTIFG: break;
        case USCI_UART_UCTXCPTIFG: break;
      }
    }
    

    Regards,


    Nikhil K

  • UART0 is connected to the back channel UART via 2.0/2.1 via the J13 shorting jumpers. If you want UART1 to connect to the PC/back channel UART you would need to remove the TX and RX shorting jumpers and add your own wired jumpers from 2.5/2.6.

  • If i want to send some data from MSP to Host pc via uart, how i can input data(is there any debug prompt/terminal of msp will appear in ccs)?
    if i add some debug prints (printf) on MSP application, where these prints suppose to appear, beacuse i dont see any prints on debug console, Debug output or output window of CCS.

    Regards,

    Nikhil K

  • Hello Nikhil,

    If you want to send data to PC via UART using MSP430, you need to write related code in your code. For example, as below:

    while (!(UCA0IFG & UCTXIFG));

    UCA1TXBUF = xxx (you want to send);

    Or in debug mode, you open the "register" window, and write the data directly into TX register 

    About "printf", in fact, "printf" also needs serial port (usually UART), that is why you can't see it in CCS window. You can go to check the definition of the "printf" function.

    Best Regards, 

    Janz Bai

  • "About "printf", in fact, "printf" also needs serial port (usually UART), that is why you can't see it in CCS window. You can go to check the definition of the "printf" function."

    I don't think this is exactly right. printf() uses the *other* UART port that communicates with the MCU via JTAG. It does not involve the MCU UART at all. Basically printf creates a memory buffer that is transferred to the host via jtag and the debug software in CCS/THeia print it to the console, usually slowly and at random times.

    So, OP, you can use printf, but you *can't* use it to send data to a terminal program like putty, unless you do some wild gyrations to re-direct stdout, which I have never understood. (And you should fflush(stdout) after every printf)

    The base MSP430 has no terminal software so there is no way to  "input data(is there any debug prompt/terminal of msp will appear in ccs)".

  • Understood, 

    For uart clock configuration, Example available in eusci_a_uart_ex1_loopbackAdvanced.c file only shows configuring reference clock from external crystal 
        * Select Port J
        * Set Pin 4, 5 to input Primary Module Function, LFXT.
        */
        GPIO_setAsPeripheralModuleFunctionInputPin(
            GPIO_PORT_PJ,
            GPIO_PIN4 + GPIO_PIN5,
            GPIO_PRIMARY_MODULE_FUNCTION
        );

        //Set DCO frequency to 1 MHz
        CS_setDCOFreq(CS_DCORSEL_0,CS_DCOFSEL_0);
        //Set external clock frequency to 32.768 KHz
        CS_setExternalClockSource(32768,0);
        //Set ACLK=LFXT
        CS_initClockSignal(CS_ACLK,CS_LFXTCLK_SELECT,CS_CLOCK_DIVIDER_1);
        //Set SMCLK = DCO with frequency divider of 1
        CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1);
        //Set MCLK = DCO with frequency divider of 1
        CS_initClockSignal(CS_MCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1);
        //Start XT1 with no time out
        CS_turnOnLFXT(CS_LFXT_DRIVE_0);


        // Configure UART pins
        //Set P2.0 and P2.1 as Secondary Module Function Input.
        /*

        * Select Port 2d
        * Set Pin 0, 1 to input Secondary Module Function, (UCA0TXD/UCA0SIMO, UCA0RXD/UCA0SOMI).
        */
        GPIO_setAsPeripheralModuleFunctionInputPin(
        GPIO_PORT_P2,
        GPIO_PIN0 + GPIO_PIN1,
        GPIO_SECONDARY_MODULE_FUNCTION
        );

    Can you please provide some reference implementation to configure clock from internal clock generators for UCA1 uart 
    Seems "msp430fr59xx_euscia0_uart_01.c" this file implements internal clock for uart but in this example everything is register read/write. Can you please provide the example implementations with api calls/driverlib functions as mentioned in eusci_a_uart_ex1_loopbackAdvanced.c 

    Regards,
    Nikhil K

  • I suggest you just take the clock code from the one example and add it to your working serial example.

**Attention** This is a public forum