#include
sbit SRCLK=P3^6;
sbit RCLK=P3^5;
sbit SER=P3^4;
void Hc595SendByte(unsigned char dat)
{
unsigned char a;
SRCLK=0;
RCLK=0;
for(a=0;a<8;a++)
{
SER=dat>>7;
dat<<=1;
SRCLK=1;
_nop_();
_nop_();
SRCLK=0;
}
RCLK=1;
_nop_();
_nop_();
RCLK=0;
}
void Delay10ms(unsigned int c) //误差 0us
{
unsigned char a,b;
for(b=c;b>0;b--)
for(a=110;a>0;a--);
}
void main(void)
{
unsigned char i,num;
while(1)
{
num=0xfe;
for(i=0;i<8;i++)
{
P0=~num;
Hc595SendByte(0xff);
num<<=1;
Delay10ms(1000);
}
}
}