悬赏
5
分 芯积分未解决
用串口调试助手调试有发送没有接收,大侠们帮忙看看呗。
#include
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
}