|
我用的是MSP430F169的板子,以下代码的功能是把串口接收到数据直接发送出去,我用串口调试助手向串口发送数据,发现板子可以正常接收数据,也能正常给TXBUF1赋值,但是PC就是收不到数据,请教各位高手指点.
#include <msp430x16x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3SEL |= 0xC0; // P3.6,7 = USART1 TXD/RXD
P3DIR |= 0X40;
BCSCTL2 |= SELM_3; // MCLK = LFXT1 (safe)
ME2 |= UTXE1 + URXE1; // Ena××e USART1 TXD/RXD
UCTL1 |= CHAR; // 8-bit character
UTCTL1 |= SSEL0; // UCLK = ACLK
UBR01 = 0x03; // 32768/9600 = 3.4
UBR11 = 0x00; //
UMCTL1 = 0x4A; // modulation
UCTL1 &= ~SWRST; // Initialize USART state machine
IE2 |= URXIE1; // Ena××e USART1 RX interrupt
_EINT();
for (;;)
{
_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
_NOP();
}
}
#pragma vector=UART1RX_VECTOR
__interrupt void usart1_rx (void)
{
while (!(IFG2 & UTXIFG1)); // USART1 TX buffer ready?
TXBUF1 = RXBUF1; // RXBUF1 to TXBUF1
}
|
|