#include<msp430x44x.h>
char MST_Data=0X00,SLV_Data=0XFF;
void Init(void);
void main(void)
{
unsigned int i;
WDTCTL=WDTPW+WDTHOLD;
Init();
_EINT();
P3OUT&=~0X020;
P3OUT|=0X020;
i=50000;
do(i–);
while(i!=0);
while(1)
{
TXBUF0=MST_Data;
LPM0;
}
}
void Init(void)
{
P1OUT=0X000;
P1DIR=0X001;
P3SEL=0X00E;
UCTL0=CHAR+SYNC+MM+SWRST;
UTCTL0=STC+SSEL1+CKPL;
UBR00=0X02;
UBR01=0X00;
UMCTL0=0;
ME1=USPIE0;
UCTL0&=~SWRST;
IE1=URXIE0;
}
#pragma vector=USART0RX_VECTOR
__interrupt void SPI0_rx(void)
{
P3OUT^=0X010;
while ((IFG1&UTXIFG0)==0);
if (U0RXBUF==SLV_Data)
{
SLV_Data=SLV_Data-1;
MST_Data=MST_Data+1;
TXBUF0=MST_Data;
P1OUT|=0X001;
P1OUT&=~0X001;
}
else
{
TXBUF0=MST_Data;
P1OUT|=0X001;
}
}
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/ceping/257773.html