keil报错,是不能直接赋予数组dat[5]={dat1,dat2,dat3,dat4,datL};这样的变量值吗?
void led_hc595_drive(unsigned char dat1,unsigned char dat2,unsigned char dat3,unsigned char dat4,unsigned char datL)
{
unsigned char dat[5]={dat1,dat2,dat3,dat4,datL};
unsigned char i,j;
for(j = 0;j < 5;j++)
{
unsigned char temp = dat[j];
for(i=0;i<8;i++)
{
HC595_DS=(temp&0x80)?1:0;
HC595_SH_CP=0;
HC595_SH_CP=1;
temp<<=1;
}
}
HC595_ST_CP = 0;//上升沿 移位寄存器的数据移到存储寄存器
HC595_ST_CP = 1;
HC595_SH_CP = 0;//拉低,提高抗干扰
HC595_ST_CP = 0;
HC595_DS = 0;
}
|