#include<msp430g2553.h>
#include<msp430.h>
void main()
{
WDTCTL=WDTPW+WDTHOLD;
CCTL0=CCIE;
CCR0=50000;
TACTL=TASSEL_2+ID1+MC_1;
P1DIR=0XFF;
P1OUT=0XFF;
_EINT();
LPM0;
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A(void)
{
volatile unsigned int i,j,flag,speed,dir;
if(flag==0)
{
P1OUT=~(0X80>>(i++));
}
else if(flag==1)
{
P1OUT=~(0X01<<(i++));
}
else
{
if(dir)
{
P1OUT=~(0X80>>(i++));
}
else
{
P1OUT=~(0X01<<(i++));
}
}
if(i==8)
{
i=0;
dir=~dir;
}
j++;
if(j==40)
{
i=0;
j=0;
flag++;
if(flag==4)flag=0;
switch(speed)
{
case 0:
TACTL&=~(ID0+ID1);
TACTL|=ID_3;
break;
case 1:
TACTL&=~(ID0+ID1);
TACTL|=ID_2;
break;
case 2:
TACTL&=~(ID0+ID1);
TACTL|=ID_1;
break;
default:
break;
}
if(flag!=3)speed++;
if(speed==4) speed=0;
}
} |