#include <msp430x14x.h>
void init_usart0(void);
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
while(1)
{
LPM1;
while(!(IFG1 & UTXIFG0));
TXBUF0 = RXBUF0;
}
}
#pragma vector = UART0RX_VECTOR
__interrupt void usart_rx(void)
{
LPM1_EXIT;
}
void init_usart0(void)
{
P3SEL |= 0x30; //P3.4,P3.5设置为usart发送接收
ME1 |= UTXE0 + URXE0; //打开发收接收使能
UCTL0 |= CHAR; //设置为8为数据
UTCTL0 |= SSEL0;//UCLK = ACLK
UBR00 = 0x03; // 32k/9600 - 3.41
UBR10 = 0x00; //
UMCTL0 = 0x4A; // Modulation
UCTL0 &= ~SWRST;
IE1 |= URXIE0;
_EINT();
}
|