#include <msp430g2553.h>
int main(void)
{
DCOCTL = 0;
BCSCTL1 = CALBC1_16MHZ;
DCOCTL = CALDCO_16MHZ;
BCSCTL1 |= DIVA_1; //ACLK =MCLK/2=8M
BCSCTL2 |= DIVS_1; //SMCLK=MCLK/2=8M
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 |= UCSWRST; // reset UART module,as well as enable UART module
UCA0CTL1 |= UCSSEL_2; // UART clock is SMCLK
UCA0BR0 |= 65; // Baud N=BCLK/rate,rate=9600,BCLK=SMCLK=8M
UCA0BR1 |= 3;
UCA0MCTL = UCBRS1; // UCBRSx=2
UCA0CTL1 &= ~UCSWRST; // UART reset end
IE2 |= UCA0TXIE; // Enable USCI_A0 TX interrupt
_EINT();
while (1);
}
// USCI A0/B0 Transmit ISR
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
UCA0TXBUF = 'A'; // TX next character
IE2 &= ~UCA0TXIE; // Disable USCI_A0 TX interrupt
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
呵呵,是这个问题,也谢谢你的耐心回答
一周热门 更多>