#include<msp430g2553.h>
#define uchar unsigned char
#define uint unsigned int
uchar com;
void ckinit()
{
UCA0CTL1|=UCSWRST;
UCA0CTL1|=UCSSEL_2;
UCA0CTL0&=~UC7BIT;
UCA0BR0=0x41;
UCA0BR1=0x03;
UCA0MCTL=0;
IE2=UCA0TXIE+UCA0RXIE;
UCA0CTL1&=~UCSWRST;
}
void delay()
{
uchar x,y;
for(x=10;x>0;x--)
for(y=110;y>0;y--);
}
void send(uchar s)
{
while((IFG2&UCA0TXIFG)==0);
UCA0TXBUF=s;
IFG2&=~UCA0TXIFG;
}
void main(void)
{
WDTCTL=WDTPW+WDTHOLD;
P1SEL|=BIT1+BIT2;
P1SEL2|=BIT1+BIT2;
ckinit();
_EINT();
while(1)
{
LPM0;
while(!(IFG2&UCA0TXIFG));
com=UCA0RXBUF;
send(com);
delay();
}
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void rec()
{
LPM0_EXIT;
}
此帖出自
小平头技术问答
我刚接触430 是个新手, 用串口助手,这些没关系吧。 您看我的程序有错误吗
一周热门 更多>