#include<msp430x14x.h>
typedef unsigned char uchar;
typedef unsigned int uint;
void ConfigUart0();
void main()
{
WDTCTL=WDTPW+WDTHOLD;
P2DIR=0XFF;
P2OUT=0x00;
ConfigUart0();
_EINT();
LPM1;
}
#pragma vector=UART0RX_VECTOR
__interrupt void Uart0_RX()
{
P2OUT=RXBUF0; //控制流水灯亮暗
}
void ConfigUart0()
{
P3SEL|=0X30;
ME1 |= UTXE0 + URXE0; // Enabled USART0 TXD/RXD
UCTL0 |= CHAR; // 8-bit character, SWRST=1
UTCTL0 |= SSEL0; // UCLK = ACLK
UBR00 = 0x03; // 9600 from 1Mhz
UBR10 = 0x00; //
UMCTL0 = 0x4A; // Modulation
UCTL0 &= ~SWRST; // Initialize USART state machine
IE1 |= URXIE0 + UTXIE0; // Enable USART0 RX/TX interrupt
}
|