- #include
- unsigned int i;
- //unsigned char RXData = 0;
- //unsigned char TXData = 0;
- unsigned char check = 0;
- int main(void)
- {
- WDTCTL = WDTPW + WDTHOLD;
- CSCTL0_H = 0xA5;
- CSCTL1 |= DCOFSEL0 + DCOFSEL1;
- CSCTL2 = SELA_3 + SELS_3 + SELM_3;
- CSCTL3 = DIVA_0 + DIVS_0 + DIVM_0;
- CSCTL4 |= XT1OFF;
- // Configure UART pins
- P2SEL1 |= BIT0 + BIT1;
- P2SEL0 &= ~(BIT0 + BIT1);
- // Configure UART 0
- UCA0CTL1 |= UCSWRST;
- UCA0CTL1 = UCSSEL_1; // Set ACLK = 32768 as UCBRCLK
- UCA0BR0 = 53; // 9600 baud
- UCA0BR1 = 0;
- UCA0MCTLW |= 0x4900; // 32768/9600 - INT(32768/9600)=0.41
- // UCBRSx value = 0x53 (See UG)
- UCA0CTL1 &= ~UCSWRST; // release from reset
- UCA0IE |= UCRXIE; // Enable RX interrupt
-
- __bis_SR_register(LPM0_bits + GIE); // LPM3 + Enable interrupt
- }
- // Echo back RXed character, confirm TX buffer is ready first
- #pragma vector=USCI_A0_VECTOR
- __interrupt void USCI_A0_ISR(void)
- {
- // switch(__even_in_range(UCA0IV,0x08))
- // {
- // case 0:break; // Vector 0 - no interrupt
- // case 2: // Vector 2 - RXIFG
- while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
- // UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
- UCA0TXBUF = 1;
- // break;
- // case 4:break; // Vector 4 - TXIFG
- // default: break;
- // }
- }
复制代码就想实现串口的收发,始终用的内部时钟(msp-exp430fr5739的板子,没接XT1晶振),看看哪里出错了、?
此帖出自
小平头技术问答
一周热门 更多>