#include<msp430g2553.h> 
 #define uint unsigned int 
 #define uchar unsigned char 
  
#define MAXCHAR 20 
 uchar  aa[MAXCHAR]; 
 uchar j=0; 
  
uchar  ATE0[]="ATE0\r\n" ;                        //关闭回显一个\n 0a(还行符) 
  
void Print_Char(uchar ch)                         //发送单个字节 
 { 
   while (!(IFG2&UCA0TXIFG));              
  UCA0TXBUF = ch;                   
 } 
  
void Print_Str(uchar *str)                      //发送字符串 
 { 
   while(*str!='\0') 
     { 
       Print_Char(*str); 
       //__delay_cycles(2000); 
       str++; 
     } 
 } 
  
void Ini_UART(void) 
 { 
   P1SEL = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD 
   P1SEL2 = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD 
   UCA0CTL1 |= UCSSEL_1;                     // CLK = ACLK         ACLK默认外部32K晶振 
   UCA0BR0 = 0x03;                           // 32kHz/9600 = 3.41                32k/19200=1.66667 
   UCA0BR1 = 0;                           // 
   UCA0MCTL = UCBRS1 + UCBRS0;               // Modulation UCBRSx = 3  
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine** 
   IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt 
   _EINT(); 
 } 
  
#pragma vector=USCIAB0RX_VECTOR                                   //接受中断 
 __interrupt void USCI0RX_ISR(void) 
 { 
   aa[j]= UCA0RXBUF;//命令存到命令数组 
   j++; 
 } 
  
int main() 
 { 
   WDTCTL = WDTPW + WDTHOLD;                 // Stop  
  Ini_UART(); 
   while(1) 
   { 
     Print_Str(ATE0);//关闭回显    
     __delay_cycles(1000000); 
   //  while(1); 
   } 
 }
 |