#include<REG52.H>
#define ui unsigned int
#define uc unsigned char
uc code tube[] = {0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40,0x00};
uc code xx[] = {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
sbit DAT = P3^4;
sbit rck = P3^5;
sbit sck = P3^6;
uc l,i,k=0;
void S_data( uc chip_4 ,uc chip_3 )
{
uc i;
rck = 0;
for(i=0;i<8;i++)
{
sck = 0;//从低位到高位
chip_4 <<= 1;
DAT = CY;
sck = 1;
}
for(i=0;i<8;i++)
{
sck = 0;//从低位到高位
chip_3 <<= 1;
DAT = CY;
sck = 1;
}
rck = 1;
}
void delay()
{
;;
}
void display(void)
{
uc j=0;
if(l == 5)
{
l = 0;
S_data(xx[k],tube[j + k]);
delay();
k++;
if (k == 8)
k = 0;
}
}
void star(void)
{
TMOD = 0X01;
TH0 = (65536-45872)/256;
TL0 = (65536-45872)%256;
EA = 1;
ET0 = 1;
TR0 = 1;
}
void time() interrupt 1
{
TH0 = (65536-45872)/256;
TL0 = (65536-45872)%256;
l++;
}
void main()
{
star();
while(1)
{
display();
}
}
|