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.

MSP430F2370: Uart communication problem

Part Number: MSP430F2370
Other Parts Discussed in Thread: TRF7970A,

Hi,

I have a custom board based on MSP430F2370 and TRF7970A. The TRF7970A has a 13.56MHz crystal and SYS_CLK of TRF7970A is connected to XIN of MSP430F2370.

The TRF7970A SYS_CLK output is configured at 6.78MHz.

I'm trying to setup UART between MSP430F2370 and external controller and it is not working. Below is my code for Oscillator setup and Uart setup of MSP430F2370.

void MCU_OscSel(){

BCSCTL1 |= XTS + XT2OFF; // ACLK = LFXT1 HF XTAL
BCSCTL3 |= LFXT1S1; // 3 – 16MHz crystal or resonator
// the TRF796x sys_clk pin works as ocillator
// it is set to 6.78 MHz (= 13.56 MHz / 2) in Trf797xInitialSettings()
// turn external oscillator on
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (ii1 = 0xFF; ii1 > 0; ii1--) // Time delay for flag to set
{
}
} while ((IFG1 & OFIFG) == OFIFG); // OSCFault flag still set?

BCSCTL2 |= SELM1 + SELM0 + SELS; // MCLK = SMCLK = HF LFXT1 (safe)

}

void UART_setup(void) // uses USCI_A0

{

P3SEL |= BIT4 + BIT5; // P3.4, P3.5 - UART mode

P3DIR |= BIT4; // P3.4 - output direction

UCA0CTL1 |= UCSWRST; // disable UART

UCA0CTL0 = 0x00;

UCA0CTL1 |= UCSSEL_2 + UCSWRST; // Source from SMCLK, keep SW Reset

UCA0BR0 = 0x3A; // Baud Rate = 115200
UCA0BR1 = 0x00;

UCA0MCTL = 0;//UCBRS_2 + UCBRS0; // Modulation UCBRSx = 2

UCA0CTL1 &= ~UCSWRST; // Initialize USCI state machine

IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt

}

Regards,

Madhusudhan

  • Hi Madhusudhan,

    Before diving into the code, please go through the troubleshooting steps on page 5 of Solutions to Common eUSCI and USCI Serial Communication issues on MSP430 MCUs

    --------------------------------

    "The following list of the most common issues experienced when debugging UART should be given special attention when evaluating a communication issue:

    ❏ Verify both devices agree on presence of a parity bit and number of stop bits

    ❏ Tools for achieving desired baud rate:

    • See the table of common baud rates and settings in the target devices family user's guide.

    • Online tools: Baud Rate Calculator ❏ When developing IrDA communication based on UART, see Implementing IrDA With the MSP430.

    ❏ Check all peripheral initialization, including:

    • Physical pin selection (RX and TX pins)

    • Communication register settings

    • Enabling of interrupts (both local and global)

    ❏ Ensure you are connecting one device's RX pin to the other device's TX pin and the reverse.

    ❏ Use the tools available (for example, IDE debugger, logic analyzer, and oscilloscope) to prove that both ends are adhering to the UART software protocol."

  • Hi Christopher,

    I have gone through that and looks like I have done everything but uart is still not working.

    The problem is that in the data transfer I'm getting junk data instead of original data.

    Please check my code above and let me know what I have done wrong.

    Regards,

    Madhusudhan

  • Hi Madhusudhan,

    Sorry for the delay in response.

    Please attempt one of the stock example code for implementing UART located here so we can determine if this is a hardware/software issue.

    -Chris

  • Hi Madhusudhan

    Have you try the example code that Chris have suggest you? Any update about your problem?

    Best regards

    Gary

  • Hi Gary,

    I'm using the uart for LIN communication (TLIN1029). When I try to send data in UART after detecting the card in iso14443a.c, I'm getting junk data at the receiving side. But when I try to send UART data in main.c after calling the NFC_findTag() function the data is going properly that too if I give a delay of atleast 1 millisec for every byte I send in UART like below. 

    for (i=0; i<20; i++)
    {
    UART_putChar(uartTxBuf[i]);
    MCU_delayMillisecond(1);
    }

    Regards,

    Madhusudhan

  • Hi Madhusudhan

    Some comments here:

    1. Use the configuration "BCSCTL3 |= LFXT1S_3;"

    2. Output the SMCLK at P1.4 check the frequency if it is 6.78MHz

    3.. Change some value around 0x3A for UCA0BR0

    Best regards

    Gary

**Attention** This is a public forum