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.

MSP430G2755: uart example

Part Number: MSP430G2755
Other Parts Discussed in Thread: MSP430G2553

我在msp430G2755上写了一段uart串口通讯程序,但运行不成功,不知什么问题?

#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
if(UCA0RXBUF==2)
{instru[0]=2;
com_p=0;
}
else if(instru[0]==2)
{instru[++com_p]=UCA0RXBUF;
if(UCA0RXBUF==3||com_p>19)
com=1; // 命令结束
}
else
{instru[com_p]=UCA0RXBUF;
com_p++;
}
if(com_p>=29) com_p=0;
}

//////////串行口初始化
void ini_usart115k()
{
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set DCO 0x86;//
DCOCTL = CALDCO_1MHZ; // 0xdb;//
P3SEL = BIT4 + BIT5 ; // P3.5 = RXD, P3.4=TXD
P3SEL2 = BIT4 + BIT5;
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 8; // 1MHz 115200
UCA0BR1 = 0; // 1MHz 115200
UCA0MCTL = UCBRS2 + UCBRS0; // Modulation UCBRSx = 5
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
}