我想利用串口调试助手发送数据然后将发送的数据发回给助手,但是不知道怎么回事,好像助手接收不到发回的数据,
这是我的程序,希望各位大神帮忙看下哪有问题:
#include"msp430g2553.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;//
P1DIR |=BIT0;
P1OUT |=BIT0;
BCSCTL1 =CALBC1_1MHZ;
DCOCTL =CALDCO_1MHZ;
P1SEL |=BIT1+BIT2;
UCA0CTL1 |=UCSWRST;
UCA0CTL1 |=UCSSEL_2;
UCA0BR0 =104;
UCA0BR1 =0;
UCA0MCTL |=UCBRS_2+UCBRF_0;
UCA0CTL1 &=~UCSWRST;
IE2 |=UCA0RXIE;
IFG2 |=UCA0RXIFG;
_EINT();
while(1);
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
P1OUT ^=BIT0;
while(!(IFG2&UCA0TXIFG))
{
UCA0TXBUF=UCA0RXBUF;
}
IFG2 &=~UCA0RXIFG;
}
此帖出自
小平头技术问答
- void uart_Init(void)
- {
- WDTCTL = WDTPW + WDTHOLD;
- BCSCTL1 = CALBC1_1MHZ;
- DCOCTL = CALDCO_1MHZ;
- P1SEL = BIT1 + BIT2 ;
- P1SEL2 = BIT1 + BIT2 ;
-
- UCA0CTL1 |= UCSSEL_2;
- UCA0BR0 = 104;
- UCA0BR1 = 0;
- UCA0MCTL = UCBRS0;
- UCA0CTL1 &= ~UCSWRST;
- IE2 |= UCA0RXIE;
- _EINT();
- }
复制代码一周热门 更多>