#include <STC15F2K60S2.H>
#define u8 unsigned char
#define u16 unsigned int
#define u32 unsigned long
u16 i;
u32 ss;
u8 code table_d[10]= {0x3f,0x06,0x5b,0x4f,0x66,\
0x6d,0x7d,0x07,0x7f,0x6f};
u8 code table_w[8] = {0X01,0X02,0X04,0X08,\
0X10,0X20,0X40,0X80};
void Timer0Init(void) //5???@11.0592MHz
{
AUXR |= 0x80; //????????1T??
TMOD &= 0xF0; //??????????
TL0 = 0xcd; //?????????
TH0 = 0xd4; //?????????
TF0 = 0; //???TF0???
TR0 = 1; //?????0??????
IE=0X82;
}
void main(void)
{
u8 k;
u8 num[8] = {0};
P0=0X00;
P27=0;
Timer0Init();
while(1)
{
for(k=0;k<8;k++)
{
num[0] = table_d[ss%10];
num[1] = table_d[ss%100/10];
num[2] = table_d[ss%1000/100];
num[3] = table_d[ss%10000/1000];
num[4] = table_d[ss%100000/10000];
num[5] = table_d[ss%1000000/100000];
num[6] = table_d[ss%10000000/1000000];
num[7] = table_d[ss%100000000/10000000];
P26=0;
P25=1;
P0 =num[k];
P26 = 1;
P25 = 0;
P0 = ~table_w[k];
}
}
}
void Timer0_Rountine(void) interrupt 1
{
i++;
if(i==1000)
{
i=0;
ss++;
}
}
|