自己写了一个串口调试程序,用串口调试助手调试,只有发送没有接收。各位高手看看是不是程序有问题啊
#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
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>