#include <msp430x24x.h>
typedef unsigned char U8;
typedef unsigned int U16;
//#define cpu_f ((double)800000)
//#define delayms(x) _delay_cycles((long)(cpu_f*(double)x/1000.0))
unsigned char const table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};//共阴数码管
void delay1ms(volatile U16 t)
{
volatile U16 i;
while(t--)
for(i=1330;i>0;i--);
}
int main(void)
{ unsigned char j;
char q;
//unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1SEL=0x00; //
P1DIR=0xFF;
P3SEL=0x00; //
P3DIR=0xFF;
P1OUT=0x00;
P3OUT=0xFF;
j=0;
q=0;
for(;;)
{
P3OUT=0xff;
P1OUT=table[j];
P3OUT=~(1<<q);
j++;
q++;
if(j==7)
{
// P3OUT=~(1<<0);
// P1OUT=table[0];
j=0;
q=0;
}
delay1ms(1);
}
//return 0;
下面这张是用CCS编译的


