Other Parts Discussed in Thread: MAX232, MSP430AFE253
Hello everyone,
I am using the sample code from TI setting up UART at 115200 Baud. However, when I echo back characters in hyperTerminal (or TeraTerm) I get gibberish for some and the right chars back for others.
I'm guessing this is a sync problem. However, I am not proficient enough with these controllers to fix it.
Maybe I need to be at 9600 baud to slow things down? Here's the code in case anyone is interested.
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1SEL |= BIT3+BIT4; // P1.3,1.4 = USART0 TXD/RXD
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0x47FF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
U0CTL |= CHAR; // 8-bit character
U0TCTL |= SSEL1; // UCLK= SMCLK
U0BR0 = 10; // 1MHz 115200
U0BR1 = 0x00; // 1MHz 115200
U0MCTL = 0x00; // 1MHz 115200 modulation
U0CTL &= ~SWRST; // Initialize USART state machine
IE1 |= URXIE0; // Enable USART0 RX interrupt
P1SEL2 |= BIT0; // Set SMCLK at P1.0
// while(1)
// {
// while (!(IFG1 & UTXIFG0));
// TXBUF0 = 'a';
// }
//_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}
#pragma vector=USART0RX_VECTOR
__interrupt void USART0_RX (void)
{
while (!(IFG1 & UTXIFG0)); // USART0 TX buffer ready?
TXBUF0 = RXBUF0; // RXBUF0 to TXBUF0
}