?? main.c
字號:
#include<msp430x14x.h>
void DISP(unsigned char Seg[])
{ unsigned char m=0;
P5SEL=0x0A; //p5.1 p5.3為外圍模式
P5DIR |=0x0A; //p5.1 p5.3為輸出模式
U1CTL=CHAR+SYNC+MM+SWRST; //設置 8字節 ISP主機模式
U1TCTL=CKPL+SSEL1+STC; //3線 ACLK時鐘
U1BR0=0x002;
U1BR1=0x000;
U1MCTL=0x000; //設置分頻
ME2 =USPIE1; //同步模塊使能
U1CTL &=~SWRST; // SPI使能
char digit[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf};
while(m<=7)
{TXBUF1=digit[Seg[m]];
m++;
}
} //End DISP
void main(void)
{ unsigned char t[8]={0,0,10,0,0,10,0,0};
unsigned char i=0;
WDTCTL=0x5A1C;
P5DIR=0x04; //p5.2輸出模式
for(;;)
{
if(P2.0==0){ t[8]={0xc0,0xc0,0xbf,0xc0,0xc0,0xbf,0xc0,0xc0};DISP(t)}
if (IFG1&0x01)
{P5OUT ^=0x04; //p5.2取反
IFG1&=0xfe;
i++;
if(i<=0x09) t[0]=i;
if(i==0x0A) {t[0]=0; i=0; t[1]+=1;}
if(t[1]==0x06){t[1]=0; t[3]+=1;}
if(t[3]==0x0A){t[3]=0; t[4]+=1;}
if(t[4]==0x06){t[4]=0; t[6]+=1;}
if(t[6]==0x0A){t[6]=0; t[7]+=1;}
if(t[7]==0x02&&t[6]==0x04) t[7]=t[6]=t[4]=t[3]=t[1]=t[0]=0;
DISP(t);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -