本人菜鸟一枚,求高手指导程序时候有问题:
#include "msp430x47x4.h" void usart(); void main(void) { WDTCTL = WDTPW+WDTHOLD; // Stop WDT FLL_CTL0 |= XCAP14PF; // Configure load caps TACTL= TASSEL_1+ID_3 + MC_1+TACLR; //定时器A的时钟源选择ACLK,8分频,增计数模式 CCTL0 = CCIE; //使能CCR0中断 CCR0 = 2047; //设定周期0.5 usart(); P2DIR=0x02; _EINT(); for(;;) { _BIS_SR(CPUOFF); _NOP(); }
} void usart(void) { UCA0CTL0 |= UCSWRST; UCA0CTL0 |= UCSSEL_1; // CLK = ACLK,32768HZ UCA0BR0 = 0x03; // 9600 UCA0BR1 = 0x00; // UCA0MCTL = 0x4A; // Modulation P2SEL |= 0x30; // P2.4,5 = USCI_A0 RXD/TXD P2DIR|=0x10; IE2=UCA0RXIE+UCA0TXIE; UCA0CTL0 &= ~UCSWRST; // **Initialize USCI state machine** }
// Echo back RXed character, confirm TX buffer is ready first #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) { P2OUT^=0x02; //while ((IFG2 & UCA0TXIFG) == 0); UCA0TXBUF =0x01; // TX -> RXed character }
|