Iam using MSP430G2553.
#include "msp430g2553.h"
int i=0;
void count()
{
while(P1IN&0x08)
{TAR=0;
}
while(!(P1IN&0x08))
{P1OUT^=0x01;
i=(TAR/1000000);
}
}
void glow()
{ //Loop forever, we work with interrupts!
switch(i)
{ case 0 : P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
break;
case 1 :{ P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT1;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 2 :{ P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT2;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 3 :{ P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT1 + BIT2;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 4 :{ P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT5;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 5 : { P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT5 + BIT1;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 6 : { P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT5 + BIT2;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 7 : { P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT5 + BIT2 + BIT1;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 8 :{ P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT4;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 9 :{ P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT4 + BIT1;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 10 :{ P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT4 + BIT2;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 11 :{ P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT4 + BIT2 + BIT1;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 12 :{ P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT4 + BIT5;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 13 : { P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT4 + BIT5 + BIT1;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 14 : { P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT4 + BIT5 + BIT2;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
case 15 :{ P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT|= BIT4 + BIT5 + BIT2 + BIT1;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
}
break;
default : { P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
P1OUT |= BIT1 + BIT2 + BIT5 + BIT4;
_delay_cycles(5000000);
i=0;
P1OUT&=~(BIT1 + BIT2 + BIT5 + BIT4);
break;
}
}
}
void main()
{WDTCTL=WDTPW + WDTHOLD;
BCSCTL1=CALBC1_1MHZ;
DCOCTL=CALDCO_1MHZ;
TA1CTL=TASSEL_2 + ID_0 + MC_2;
P1DIR|=0x01;
P1DIR|=BIT1 + BIT2 + BIT4 + BIT5;
P1REN|=BIT3;
while(1)
{count();
glow();
}
}