Other Parts Discussed in Thread: MSP430G2231
hi every one..!!
i am making a small project on msp430 launch pad with help of msp430g2231 ic ,which is simple counter 0 to 99.
i want to flash both segment together. such as 11 ,12, 13 so on..for individual display it is ok so what to do for flashing both segment together. ??????
and my code is following..
#include"msp430g2231.h"
void delay();
void delay_short();
void control_pin(void);
void data(void);
void data1(int num);
void data2_dec(int num);
void num_display_unit();
void num_display_dec();
void main()
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR|=0xff;
P1OUT|=0xff;
P2SEL&=0x00;
P2DIR|=0xc0;
while(1)
{
unsigned int i,j;
for(i=0;i<10;j++)
{
for(j=0;j<10;j++)
{
if(i>0)
{
num_display_dec();
data2_dec(i);
num_display_unit();
data1(j);
}
else
{
num_display_unit();
data1(j);
}
}
i++;
}
}
}
void delay()
{
unsigned int i=50000;
do
i--;
while(i!=0)
;
}
void delay_short()
{
unsigned int i=30000;
do
i--;
while(i!=0)
;
}
void num_display_unit()
{
P2OUT&=0x00;
P2OUT|=0x40;
}
void num_display_dec()
{
//blink1
P2OUT&=0x00;
P2OUT|=0x80;
}
void data1(int num)
{
switch(num)
{
case 1:
P1OUT=0x7f;
P1OUT&=0x3e;
delay();
delay();
break;
case 2:
P1OUT=0x7f;
P1OUT&=0x44;
delay();
delay();
break;
case 3:
P1OUT=0x7f;
P1OUT&=0x14;
delay();
delay();
break;
case 4:
P1OUT=0x7f;
P1OUT&=0x32;
delay();
delay();
break;
case 5:
P1OUT=0x7f;
P1OUT&=0x11;
delay();
delay();
break;
case 6:
P1OUT=0x7f;
P1OUT&=0x01;
delay();
delay();
break;
case 7:
P1OUT=0x7f;
P1OUT&=0x3c;
delay();
delay();
break;
case 8:
P1OUT=0x7f;
P1OUT&=0x00;
delay();
delay();
break;
case 9:
P1OUT=0x7f;
P1OUT&=0x10;
delay();
delay();
break;
case 0:
P1OUT=0x7f;
P1OUT&=0x08;
delay();
delay();
break;
default :
break;
}
}
void data2_dec(int num)
{
switch(num)
{
case 1:
P1OUT=0x7f;
P1OUT&=0x3e;
delay_short();
break;
case 2:
P1OUT=0x7f;
P1OUT&=0x44;
delay_short();
break;
case 3:
P1OUT=0x7f;
P1OUT&=0x14;
delay_short();
break;
case 4:
P1OUT=0x7f;
P1OUT&=0x32;
delay_short();
break;
case 5:
P1OUT=0x7f;
P1OUT&=0x11;
delay_short();
break;
case 6:
P1OUT=0x7f;
P1OUT&=0x01;
delay_short();
break;
case 7:
P1OUT=0x7f;
P1OUT&=0x3c;
delay_short();
break;
case 8:
P1OUT=0x7f;
P1OUT&=0x00;
delay_short();
break;
case 9:
P1OUT=0x7f;
P1OUT&=0x10;
delay_short();
break;
case 0:
P1OUT=0x7f;
P1OUT&=0x08;
delay_short();
break;
default :
break;
}
}