手里有一个launchpad g2553的板子想学习430 就看了看书然后写了这么个程序发现用串口助手调试都不回来数啊。。。求大神指教
#include "msp430g2553.h"
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= BIT2; //P1.2 UART_TX
P1DIR &=~BIT1; //P1.2 UART_RX
P1SEL |= BIT1+BIT2; //select P1.1 and P1.2 as UART port
P1SEL2 |= BIT1+BIT2;
UCA0CTL1 |= UCSSEL_2;
DCOCTL = CALDCO_1MHZ;
UCA0BR0 = 104 ; // 1MHz 9600
UCA0BR1 = 0;
UCA0MCTL = 0x02;
UCA0CTL1 &= ~UCSWRST;
IE2 |= UCA0RXIE;
return 0;
}
#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCIA0RX_ISR (void)
{
while(!(IFG2&UCA0TXIFG));
UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
}
#include "msp430g2553.h"
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= BIT2; //P1.2 UART_TX
P1DIR &=~BIT1; //P1.2 UART_RX
P1SEL |= BIT1+BIT2; //select P1.1 and P1.2 as UART port
P1SEL2 |= BIT1+BIT2;
UCA0CTL1 |= UCSSEL_2;
DCOCTL = CALDCO_1MHZ;
UCA0BR0 = 104 ; // 1MHz 9600
UCA0BR1 = 0;
UCA0MCTL = 0x02;
UCA0CTL1 &= ~UCSWRST;
IE2 |= UCA0RXIE;
return 0;
}
#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCIA0RX_ISR (void)
{
while(!(IFG2&UCA0TXIFG));
UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
}