|
#include <msp430x14x.h>
void Init(void);
unsigned char j,count;
#define Address 0x01 //地址
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
Init();
_EINT();
while(1);
}
void Init(void)
{
UCTL0&=~SWRST;
UCTL0 = 0x10;//CHAR;
UTCTL0 = 0x10; // UCLK = ACLK
UBR00 = 0x0D; // 32k/2400 - 13.65
UBR10 = 0x00; //
UMCTL0 = 0x6B; // Modulation
ME1 |= UTXE0 + URXE0; // Ena××e USART0 TXD/RXD
IE1 |= URXIE0; // Ena××e USART0 RX interrupt
P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD
P3DIR |= 0x5f; // P3.4 output direction
P3OUT &=~BIT6; //P3.6为1487的收发控制线P3.6=0为接收,
//P3.6=1处于发送状态,上一帖此处注释有误
}
#pragma vector=UART0RX_VECTOR
__interrupt void usart0_rx (void)
{
if(RXBUF0==0x01)
P3OUT |=BIT6;
TXBUF0=RXBUF0;
while((UTCTL0&0x01)==0);
P3OUT &=~BIT6;
}
/*为什么进不了中断,不能接收!!!!请教!!!!!
|
|