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.

MSP430FR2311: MSP430FR2311 UART not working

Part Number: MSP430FR2311

Hello,

We are using the following code for transmitting data from UART. For this, we are using the MSP430FR2311 controller. After running our code, we are not receiving data on the serial monitor.

Thank You!


#include <msp430.h>
#include <msp430fr2311.h>


/**
* main.c
*/

unsigned int receiveData = 0;

void oscillatorSet(void)
{
__bis_SR_register(SCG0); // disable FLL
CSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference source
CSCTL1 = DCOFTRIMEN_1 | DCOFTRIM0 | DCOFTRIM1 | DCORSEL_3; // DCOFTRIM=3, DCO Range = 8MHz
CSCTL2 = FLLD_0 + 243; // DCODIV = 8MHz
__delay_cycles(3);
__bic_SR_register(SCG0); // enable FLL
}

void Delay_ms(unsigned int ms)
{
while(ms--)
{
__delay_cycles(1000);
}
}

void uartInit(void)
{
P1SEL0 |= BIT6 | BIT7; // Configure UART pins set 2-UART pin as second function
// Configure UART

UCA0CTLW0 |= UCSWRST; //Sets software reset enable
UCA0CTLW0 |= UCSSEL_2; // Set SMCLK as BRCLK to be used for baud rate of 9600

// Baud Rate set to 9600

UCA0BR0 = 52;
UCA0MCTLW = 0x4900;
UCA0BR1 = 1;

PM5CTL0 &= ~LOCKLPM5;

UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI

}

void uartSend(void)
{
while(!(UCA0IFG & UCTXIFG));
UCA0TXBUF = 0x02;
}

void uartReceive(void)
{
while(!(UCA0IFG & UCRXIFG));
// UCA0RXBUF = UCA0TXBUF;
receiveData = UCA0RXBUF;
}

int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
oscillatorSet();
uartInit();

PM5CTL0 &= ~LOCKLPM5;

// __delay_cycles(100);

while(1)
{
// uartReceive();
Delay_ms(100);
uartSend();
}

}

  • > UCA0BR1 = 1;

    In User Guide (SLAU445I) Table 22-5, the third column is actually UCOS16, so try instead

    >  UCA0MCTLW |= UCOS16;  // Per SLAU445I Table 22-5

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

    >  UCA0TXBUF = 0x02;

    Many terminal emulators won't display anything for ASCII code 0x02, so I suggest something printable. The character 'U' (0x55) shows up well on an oscilloscope:

    > UCA0TXBUF = 'U'; // 0x55 is printable and also useful for a scope

**Attention** This is a public forum