以下是TI官网上的参考例程,仔细看就能发现他的波特率设置跟用户手册上写的是不一致的
void initUart()
{
// Configure UART pins P2.0 & P2.1
UART2_PORT |= UART1_PIN + UART2_PIN;
UART1_PORT &= ~(UART1_PIN + UART2_PIN);
// Configure UART 0
UCA0CTL1 |= UCSWRST;
UCA0CTL1 = UCSSEL_2; // Set SMCLK as UCLk
UCA0BR0 = 156 ; // 9600 baud
// 8000000/(9600*16) - INT(8000000/(9600*16))=0.083
UCA0BR1 = 0;
// UCBRFx = 1, UCBRSx = 0x49, UCOS16 = 1 (Refer User Guide)
UCA0MCTLW = 0x4911 ;
UCA0IE |= UCRXIE; // Enable RX interrupt
UCA0CTL1 &= ~UCSWRST; // release from reset
memset(uartRXBuf,0,sizeof(uartRXBuf));
} |