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-EXP430FR5969: MSP-EXP430FR5969

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

Hello,

I want to take some string using UART and return the same back using interrupt. i am unable to write the proper programme. Also how to implement this code?

should I short TXD & RXD pins? Or should i use the USB to wire cable as shown in image?

  

Also help with the code.

#include <msp430.h> 
#include <driverlib.h>
#include <msp430fr5969.h>


volatile unsigned int i;

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  PM5CTL0 &= ~LOCKLPM5;
  P4DIR |= BIT6;
  P1DIR |= 0x01;                             // All P1.x outputs
  P1OUT |= 0x01;
  P4OUT |= BIT6;

  P2SEL0 =  0x00;//(BIT5 + BIT6);
  P2SEL1 |=  0x60;//BIT5 + BIT6;

  UCA0CTL1 |= UCSSEL_1;                     // CLK = ACLK
     UCA0BR0 = 0x03;                           // 32kHz/9600 = 3.41
     UCA0BR1 = 0x00;                           //
     UCA0MCTLW |= 0x0021;//UCA0MCTL = UCBRS1 + UCBRS0;               // Modulation UCBRSx = 3
     UCA0IE |= 0x000F;

     UCA0CTL1 &= ~UCSWRST;                     
    
    UCA0TXBUF = '1';

     __bis_SR_register(GIE);// __enable_interrupt();

}

 #pragma vector = USCI_A0_VECTOR
 __interrupt void USCI_A0_ISR(void) {
 switch(__even_in_range(UCA0IV,18))
 {//here i toggeled leds just to see whether the interrupt has occured or not
 case 0x00: P1OUT ^= BIT0;//Vector 0: No interrupts
break;
 case 0x02: P1OUT ^= BIT0;// Vector 2: UCRXIFG
 break;
 case 0x04: P4OUT ^=BIT6;// Vector 4: UCTXIFG
 break;
 case 0x06: P1OUT ^= BIT0;// Vector 6: UCSTTIFG
 break;
 case 0x08: P1OUT ^= BIT0;// Vector 8: UCTXCPTIFG
 
 break;
 default: break;
 }
 }

  • Hi,

    <<< I want to take some string using UART and return the same back using interrupt.
    Which hardware sends your string and which hardware is receiver?
  • Hello Tushar,
    I would recommend you to start with the code examples available from the TI-Resource Explorer coming with the our IDE Code Composer Studio (CCS), which is available for download from the TI web page.

    When you open the Resource Explorer in CCS and go on the left window to Software >> MSP430Ware - v3.80.04.05 >> Devices >> MSP430FR5XX_6XX >> MSP430FR5969 >> Peripheral Examples >> Register Level you can find various examples including multiple for UART . There is also a simple loop back code example msp430fr59xx_euscia0_uart_03.c
    This is a tested code example, which you can use to verify your HW. After successful verification, you could modify it for your purposes step by step.

    /* --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 - USCI_A0 External Loopback test @ 115200 baud
    //
    // 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. If data is incorrect P1.0 LED is
    // turned ON.
    // ACLK = n/a, MCLK = SMCLK = BRCLK = default DCO = 1MHz
    //
    //
    // MSP430FR5969
    // -----------------
    // RST -| P2.0/UCA0TXD|----|
    // | | |
    // -| | |
    // | P2.1/UCA0RXD|----|
    // | |
    // | P1.0|---> LED
    //
    // P. Thanigai
    // Texas Instruments Inc.
    // August 2012
    // Built with CCS V4 and IAR Embedded Workbench Version: 5.5
    //******************************************************************************
    #include <msp430.h>

    volatile unsigned char RXData = 0;
    volatile unsigned char TXData = 1;

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

    // Configure GPIO
    P1OUT &= ~BIT0; // Clear P1.0 output latch
    P1DIR |= BIT0; // For LED on P1.0
    P2SEL1 |= BIT0 | BIT1; // USCI_A0 UART operation
    P2SEL0 &= ~(BIT0 | BIT1);

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

    // Configure USCI_A0 for UART mode
    UCA0CTLW0 = UCSWRST; // Put eUSCI in reset
    UCA0CTL1 |= UCSSEL__SMCLK; // CLK = SMCLK
    UCA0BR0 = 8; // 1000000/115200 = 8.68
    UCA0MCTLW = 0xD600; // 1000000/115200 - INT(1000000/115200)=0.68
    // UCBRSx value = 0xD6 (See UG)
    UCA0BR1 = 0;
    UCA0CTL1 &= ~UCSWRST; // release from reset
    UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

    while (1)
    {
    while(!(UCA0IFG & UCTXIFG));
    UCA0TXBUF = TXData; // Load data onto buffer

    __bis_SR_register(LPM0_bits | GIE); // Enter LPM0, interrupts enabled
    }
    }

    #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,USCI_UART_UCTXCPTIFG))
    {
    case USCI_NONE: break;
    case USCI_UART_UCRXIFG:
    RXData = UCA0RXBUF; // Read buffer
    if(RXData != TXData) // Check value
    {
    P1OUT |= BIT0; // If incorrect turn on P1.0
    while(1); // Trap CPU
    }
    TXData++; // increment data byte
    __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 on reti
    break;
    case USCI_UART_UCTXIFG: break;
    case USCI_UART_UCSTTIFG: break;
    case USCI_UART_UCTXCPTIFG: break;
    }
    }

    Best regards
    Peter
  • I suggest you start with Example msp430fr59xx_euscia0_uart_03.c (slac536k, "Tools and Software" on the Product page).

    To get a physical loopback, jumper between the TXD and RXD pins.
  • P2SEL1 |= BIT0 | BIT1; // USCI_A0 UART operation
    P2SEL0 &= ~(BIT0 | BIT1);
    Your code has mentioned above lines.

    But for MSP-EXP430FR5969, RXD & TXD pins are 2.6 2.5,
    So i think the code should be as mentioned below
    Correct if iam wrong.
    P2SEL1 |= BIT5 | BIT6; // USCI_A0 UART operation
    P2SEL0 &= ~(BIT5 | BIT6);

    Also instead of checking for wrong data, iput check for the correct data and changed as follows

    if(RXData == TXData) // Check value
    {
    P1OUT |= BIT0; // If incorrect turn on P1.0
    while(1); // Trap CPU
    }

    But still it is not working.
  • There is no special hardware. I just have MSP-EXP430FR5969 development board connected to my PC and using Code Composer Studio.
  • > But for MSP-EXP430FR5969, RXD & TXD pins are 2.6 2.5,
    Per the Launchpad UG (SLAU535B) section 6, P2.0/.1 (UCA0) are connected to back-channel TXD/RXD (J13).

    Per data sheet (SLAS704F) Table 6-54, P2.5/.6 are UCA1. They are available on J4, where they are -- just to confuse things -- also marked "TXD/RXD". But they aren't what you want.
  • What s/w do you have on your PC to read from a COM port and send back to LP?
    Do you know how to find a COM port used by the back-channel?
  • Hello Tushar,
    just to clean things a bit up.
    As mentioned by Bruce, the back channel UART to PC is at P2.1/RX and P2.0/TX, displayed in the schematics of the LP on page 37 of the LP User's Guide www.ti.com/.../slau535b.pdf .
    So if you intend to use the communication to the PC, you need to use those pins. In the datasheet in the IO schematics section, you can find the details on the control bit selection necessary to select a certain IO functionality.
    As you have been mentioning also the PC, we need to clarify also the HW state, you're using, as the PC and the MSP430 loop back cannot work at the same time. Keep in mind the PC TX and MSP430 TX would be pushing against each other. Maybe, that's also one of the reasons, why you're not receiving data.
    So please make sure, if you're testing the MSP430 only loop back, the TX from PC needs to be disconnected from the MSP430 TX. These are the jumpers at J13, which in this case need to be disconnected.
    In the case, where you're operating the UART with the PC, the short between your MSP TX and RX needs to be removed.
    If you use for these two options the jumpers at J13 only, you basically cannot make a mistake.
    Maybe you could give us a kind of update of the status and your setup, addressing the mentioned points above. Many thanks in advance.

    Best regards
    Peter

**Attention** This is a public forum