Hello. I have configured UART at 9600 baud rate, running off of the 16MHz SMCLK. However I am receiving the wrong characters on the terminal (I'm using Putty to display). For example when I send 'C' I receive "GtAGtGtGtA" in an order similar to that.
Here's my code:
void configUART()
{
UCA0CTL1 |= UCSWRST; // set software reset of uart
UCA0CTL0 = 0; // default mode...8 data bits, 1 stop bit, async
UCA0CTL1 |= BIT7; //SMCLK, which is set to 16MHz
// for baud of 9600 we want prescalar = 1666; that's 130 + 6*256
UCA0BR1 = 6;
UCA0BR0 = 130;
UCA0MCTL |= UCBRS_6; // UCBRSx = 6
P1DIR |= BIT2; // select output pin
P1SEL |= BIT2; // choose UART option for pin
P1SEL2 |= BIT2;
UCA0CTL1 &= ~UCSWRST;
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
configSubMainClock16MHz();
configUART();
_BIS_SR(GIE); // enable global interrupts
while(1)
{
while(!(IFG2 & UCA0TXIFG));
UCA0TXBUF = 'C';
}
I don't know why I'm getting such random transmission.