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.

UART setup

Other Parts Discussed in Thread: MSP430F249

Hello Ti employees,

I set UART as shown to communicate with Hercules HW or Terminal console. However, I sent a character to computer, the Hercules window received different letters. Here is my code for UART in MSP430F249.

Anyone can help me to tackle this problem?

///////////////////////////

void initUart()
{
  // Configure UART pins P3.4 & P3.5
  UART_PORT0 |= UART_PIN4 + UART_PIN5;
      // Configure UART 0
  UCA0CTL1 |= UCSWRST;
  UCA0CTL1 |= UCSSEL_2;                      // Set SMCLK as UCLk
  UCA0CTL0 |= UCPEN+UCPAR;
  UCA0BR0 = 8;                              // 115200 baud
  // 16000000/(115200*16) - INT(16000000/(115200*16))=
  UCA0BR1 = 0;
  // UCBRFx = 11, UCBRSx = 0, UCOS16 = 1 (Refer User Guide)
  UCA0MCTL = 0xB1;
//  UCA0IE |= UCRXIE;                         // Enable RX interrupt

  UCA0CTL1 &= ~UCSWRST;                     // release from reset

//  memset(uartRXBuf,0,sizeof(uartRXBuf));
}

int main(void)
{
//  int i;
  WDTCTL = WDTPW + WDTHOLD;                 // Stop Watchdog Timer

  DCOCTL = 0;                               // Select lowest DCOx and MODx settings
  BCSCTL1 = CALBC1_16MHZ;                   // Set DCO to 8MHz
  DCOCTL = CALDCO_16MHZ;
//  P2OUT |= 0X00;
  P2DIR |= 0x08;

  initUart();

  sendByte('2');  // THIS LIINE
  P2OUT |= 0X08;
  while(1)
  {
  }  
}

//////////////////////

**Attention** This is a public forum