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.
因为需要我想使用PC传数据给串口0,串口0再给串口1,由串口1发出给外设。因为实现不了功能所以我就弄了下面这个测试程序,单独测试串口0与串口1。发现只有串口0可以把PC发来数据传回PC,而串口1却不能。所以很疑惑,我最近两天才接触MSP430,麻烦大侠能告诉我原因。
#include <msp430x14x.h> void UART0_Init(void); void UART1_Init(void); void main(void) { WDTCTL = WDTPW + WDTHOLD; UART0_Init(); UART1_Init(); while(1); } void UART0_Init(void) { P3SEL |= BIT4; P3SEL |= BIT5; P3DIR |= BIT4; ME1 |= UTXE0 + URXE0; UCTL0 |= CHAR; UTCTL0 |= SSEL0; UBR00 = 0x03; UBR10 = 0x00; UMCTL0 = 0x4A; UCTL0 &= ~SWRST; IE1 |= URXIE0; _BIS_SR(LPM3_bits + GIE); } #pragma vector=USART0RX_VECTOR __interrupt void usart0_rx (void) { _BIS_SR(GIE); while (!(IFG1 & UTXIFG0)); TXBUF0 = RXBUF0; } void UART1_Init(void) { P3SEL |= BIT6; P3SEL |= BIT7; P3DIR |= BIT6; ME2 |= UTXE1 + URXE1; UCTL1 |= CHAR; UTCTL1 |= SSEL0; UBR01 = 0x03; UBR11 = 0x00; UMCTL1 = 0x4A; UCTL1 &= ~SWRST; IE2 |= URXIE1; _BIS_SR(LPM3_bits + GIE); } #pragma vector=USART1RX_VECTOR __interrupt void usart1_rx (void) { while (!(IFG2 & UTXIFG1)); TXBUF1 = RXBUF1; }