悬赏
5
分 芯积分已解决
最佳答案
2014-10-10 17:53
我咋觉得是因为你忘记关看门狗了,然后隔一段时间复位发送一个A,隔一段时间又复位发送一个A了呢?
#include
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
}