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.

MSP430FR2476: MSP430FR2476TRHB UART0 TXD

Part Number: MSP430FR2476

hi

IC:MSP430FR2476TRHB

UART0:P1.4--TXD0,P1.5--RXD0

UART 0 can enter the receive interrupt, and the data in UCA0RXBUF is correct. Single-step debugging, can enter the transmit interrupt, and the data in UCA0TXBUF is correct, but the host computer software can not receive data. Oscilloscope test TXD0 port, no signal output.

Add SYSCFG3|=USCIA0RMP; the fault remains.

The host computer software and serial line have been ruled out no problem, the hardware connection is also no problem. Tried several boards are the same fault!

The configuration of URAT1 is the same as that of UART0, and the serial port sends and receives data normally.

//IO

P1DIR |= 0xff; // Set unuse pins to output direction
P1SEL0 |= BIT2+BIT4+BIT5; // P1.4-P1.5 UART

// Setup USCI_A0  9600 n 8 1
UCA0CTLW0 |= UCSWRST; // **Put state machine in reset**
UCA0CTLW0 |= UCSSEL_2; // SMCLK

// UCA0BR0 = 26;
// UCA0BR1 = 0;
// UCA0MCTLW = 0xB600 | UCOS16 | UCBRF_1;

UCA0BR0 = 52; // 8MHz 9600 (see User's Guide)
UCA0BR1 = 0; // 8MHz 9600
UCA0MCTLW = 0x4900 | UCOS16 | UCBRF_1;

UCA0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A1 RX interrupt

#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch (__even_in_range(UCA0IV, 4))
{
case 0: break; // No interrupt
case 2: // RXIFG
{
RX232_BUFF0[RX232_IndexW0]=UCA0RXBUF;//FIFO
// while ((UCA1IFG&UCRXIFG));

RX232_IndexW0++;
if(( RX232_BUFF0[RX232_IndexW0-2] == 0x0D)&&( RX232_BUFF0[RX232_IndexW0-1] == 0x0A))
{
RX232_IndexW0=0;
REC232_FLAG0=1; 
}
if(RX232_IndexW0 >=RX232BUF_SIZE0)
{
RX232_IndexW0=0;
}

break;
}
case 4: // TXIFG
{
if(TX232_OutLen0>0) //FIFO
{
TX232_OutLen0--; 
UCA0TXBUF=TX232_BUFF0[TX232_IndexR0];
while (!(UCA0IFG&UCTXIFG));
if(++TX232_IndexR0 >= TX232BUF_SIZE0)
{
TX232_IndexR0=0;
}
}
else
{
UCA0IE &= ~UCTXIE; 
}
break;
}
default: break;
}

  • Can you try the example first. All of them is using UCA0. If you want to change the GPIO, please check this code. 

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2018, 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--*/
    //******************************************************************************
    //  MSP430FR267x Demo - eUSCI_A0 UART echo at 4800 baud using BRCLK = 32768Hz.
    //
    //  Description: This demo echoes back characters received via a PC serial port.
    //  ACLK is used as UART clock source and the device is put in LPM3.
    //  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 = REFO = 32768Hz, MCLK = SMCLK = DCODIV ~1MHz.
    //
    //                MSP430FR2676
    //             -----------------
    //         /|\|                 |
    //          | |                 |
    //          --|RST              |
    //            |                 |
    //            |                 |
    //            |     P5.2/UCA0TXD|----> PC (echo)
    //            |     P5.1/UCA0RXD|<---- PC
    //            |                 |
    //
    //   Longyu Fang
    //   Texas Instruments Inc.
    //   August 2018
    //   Built with IAR Embedded Workbench v7.12.1 & Code Composer Studio v8.1.0
    //******************************************************************************
    #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
    
      // Configure UART pins
     // SYSCFG3|=USCIA0RMP;                       //Set the remapping source
      P1SEL0 |= BIT4 | BIT5;                    // set 2-UART pin as second function
    
      // Configure UART
      UCA0CTLW0 |= UCSWRST;
      UCA0CTLW0 |= UCSSEL_1;                    // set ACLK as BRCLK
    
      // Baud Rate calculation. Referred to UG 17.3.10
      // (1) N=32768/4800=6.827
      // (2) OS16=0, UCBRx=INT(N)=6
      // (4) Fractional portion = 0.827. Refered to UG Table 17-4, UCBRSx=0xEE.
      UCA0BR0 = 6;                              // INT(32768/4800)
      UCA0BR1 = 0x00;
      UCA0MCTLW = 0xEE00;
    
      UCA0CTLW0 &= ~UCSWRST;                    // Initialize eUSCI
      UCA0IE |= UCRXIE;                         // Enable USCI_A0 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_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:
          while(!(UCA0IFG&UCTXIFG));
          UCA0TXBUF = UCA0RXBUF;
          __no_operation();
          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;
        P1REN = 0xFF; P2REN = 0xFF;
        P1OUT = 0x00; P2OUT = 0x00;
    }
    
     

**Attention** This is a public forum