配合时序图看看,SCK如果放错,怎么也出不来数据的,上个月被虐的很惨呀!
void Write_CS5530(unsigned char Dat)
{
unsigned char Count;
for( Count=0; Count<8; Count++ )
{
if(Dat & 0x80)
{SET_ADI;}
else
{CLR_ADI;}
delay_us(1);
SET_ADSCK;
delay_us(1);
CLR_ADSCK;
delay_us(1);
Dat <<= 1;
}
CLR_ADI;
delay_us(1);
}
//
unsigned char Recive_CS5530(void)
{
unsigned char Count;
unsigned char Dat=0;
CLR_ADI;
delay_us(3);
for( Count=0; Count<8; Count++ )
{
SET_ADSCK;
delay_us(1);
Dat <<= 1;
if( GET_ADO ) Dat |= 0x01 ;
CLR_ADSCK;
delay_us(1);
}
return(Dat);
}
|