还有595级联八个级联 输出IO口数据很乱 求救!
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit STC = P1^4;
sbit SHC = P1^3;
sbit DS = P1^2;
sbit C1 = P1^1;
sbit C2= P1^0;
sbit C3= P3^7;
sbit C4=P3^6;
sbit C5=P3^3;
sbit C6=P3^2;
sbit C7=P3^1;
sbit C8=P3^0;
uchar code shu[9]={0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd,0xfd};
void yiwei(uchar *d)
{
uchar j,q;
for(q=0;q<8;q++)
{
for(j=0;j<8;j++)
{
DS=(d[q]<<j)&0x80;//高位在前
SHC=0;
SHC=1;
}
switch(q)
{
case 0:C1=1;break;
case 1:C2=1;break;
case 2:C3=1;break;
case 3:C4=1;break;
case 4:C5=1;break;
case 5:C6=1;break;
case 6:C7=1;break;
case 7:C8=1;break;
}
}
STC=0;
STC=1;
}
/*void chuli()
{
shu[0]=ca
} */
void main()
{
yiwei(shu);
/* C2= 1;
C3= 1;
C4=1;
C5=1;
C6=1;
C7=1;
C8=1; */
} |