本人参加利尔达的研讨会得到了这套工具。觉得挺不错的,从TI的网站上下载了MSP430F2274的UART例程来跑,编译后下载到430里运行有问题,430只能返回PC串口发给它的第一个字符,然后就没有反应了。虽然还能进接收中断但是执行完这句,串口也没有数据发出来。下面是程序,大家帮忙看看怎么回事? //****************************************************************************** // MSP430F22x4 Demo - USCI_A0, 9600 UART Echo ISR, DCO SMCLK // // Description: Echo a received character, RX ISR used. Normal mode is LPM0. // USCI_A0 RX interrupt triggers TX Echo. // Baud rate divider with 1MHz = 1MHz/9600 = ~104.2 // ACLK = n/a, MCLK = SMCLK = CALxxx_1MHZ = 1MHz // // MSP430F22x4 // ----------------- // /|| XIN|- // | | | // --|RST XOUT|- // | | // | P3.4/UCA0TXD|------------> // | | 9600 - 8N1 // | P3.5/UCA0RXD|<------------ // // A. Dannenberg // Texas Instruments Inc. // April 2006 // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.41A //****************************************************************************** #include "msp430x22x4.h"
void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF) { while(1); // If calibration constants erased // do not load, trap CPU!! } BCSCTL1 = CALBC1_1MHZ; // Set DCO DCOCTL = CALDCO_1MHZ; P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 104; // 1MHz 115200 UCA0BR1 = 0; // 1MHz 115200 UCA0MCTL = UCBRS2 + UCBRS0; // Modulation UCBRSx = 5 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled }
// Echo back RXed character, confirm TX buffer is ready first #pragma vector=USCIAB0RX_VECTOR __interrupt void USCI0RX_ISR(void) { while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready? UCA0TXBUF = UCA0RXBUF; // TX -> RXed character } |