Hello. I have written a program that simply sends a character over UART at baudrate of 115200.
MSP should send charater 'U' (0b1010101), but instead I'm getting incorrect output in terminal : '²' (0b11111101). Is there something wrong with my modulation settings or something else?
void main(void) {
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// SETUP ACLK
PJSEL0 |= BIT4;
PJSEL1 &= ~BIT4;
CSCTL0_H = 0xA5;//CSKEY password
CSCTL2 = SELA_0 + SELS_0 + SELM_0; // set ACLK = XT1; MCLK = ACLK
CSCTL3 = DIVA_0 + DIVS_1 + DIVM_0; // SMCLK=MCLK/4
CSCTL4 |= (XTS + XT2OFF + XT1DRIVE1);
CSCTL4 &= ~(XT1BYPASS + XT1OFF);
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
// Configure UART @ UCA0
// Configure UART pins
P2SEL1 |= BIT0 + BIT1;
P2SEL0 &= ~(BIT0 + BIT1);
UCA0CTL1 |= UCSWRST;
UCA0CTL1 = UCSSEL_1; // Set ACLK = 8MHz as UCBRCLK
//BAUD RATE 115200bps @ 8MHz WITH UCOS=1
UCA0BR0 = 4;
UCA0BR1 = 0;
UCA0MCTLW = (UCOS16 + UCBRS6 + UCBRS4 + UCBRS2 + UCBRS0 + UCBRF2 + UCBRF0);//UCOS=1 UCBRF=5 UCBRS=0x55
UCA0CTL1 &= ~UCSWRST; // release from reset
UCA0IE |= UCRXIE; // enable RX interrupt
/////////////////////////////////////////////////////////////////////////////////////////////
unsigned char datasend = 'U';
while(1)
{
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = datasend;
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,0x08))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
RX_char = UCA0RXBUF;
Flags.RX_Received = 1;
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}