本帖最后由 浅唱246 于 2014-1-14 20:57 编辑
把程序写进去后,用串口调试助手发送数,只有发送,没有接收,请各位高手帮忙看看。新手,希望大家多多帮忙啊。十分感谢大家啦
#include <msp430f4783.h>
void main(void)
{
unsigned char i;
P4SEL |= BIT0; //设置P4.0为UART1的TXD
P4SEL |= BIT1; //设置P4.1为UART1的RXD
P4DIR |= BIT0; //P4.0为输出管脚
WDTCTL = WDTPW+WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP11PF; // Configure load caps
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xff; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
UCA1CTL1 |= UCSSEL_1; // CLK = ACLK
UCA1BR0 = 0x03; // 32k/9600 - 3.41
UCA1BR1 = 0x00; //
UCA1MCTL = 0x06; // Modulation
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
// ME2 |= UCA1TXIE+ UCA1RXIE; //使能UART1的TXD和RXD
IE2 |= UCA1RXIE; //使能UART1的RX中断
IE2 |= UCA1TXIE; //使能UART1的TX中断
_BIS_SR(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB1RX_VECTOR
__interrupt void USCIA1RX_ISR (void)
{
while(!(IFG2&UCA1TXIFG));
UCA1TXBUF = UCA1RXBUF; // TX -> RXed character
} |