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.

G2553 串口通信 如何使用

Other Parts Discussed in Thread: MSP430G2553

求教串口通信如何使用。我想将数据发到上位机显示。看了官方例程如下

#include "msp430g2553.h"

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt

for(;;)
{
__bis_SR_register(LPM0_bits + GIE);
}

}

// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
}

。但是不知道然后怎么用。请各位老师指点一下

  • 你好,这个范例程序演示的是单片机串口收到一个数据,然后把这个数据再发回去。

    你可以用上位机和G2553通讯,上位机设置串口号可以在设备管理器看到,我的是COM18,

    波特率9600,无校验,数据位8,停止位1。

    如果是Launchpad 1.5 版本的话设置如图:

    用的是硬件Uart。

    设置好之后就OK啦,在我这边运行的结果如下图: