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();
}
}