
當(dāng)1腳拉低時(shí),八位并行數(shù)據(jù)被壓入鎖存器,但與此同時(shí),D7也已經(jīng)從7腳輸出,因此只要再循環(huán)7次將數(shù)據(jù)讀出即可
uchar ReadExport(void)
{
unsigned char i=0,receive_date=0;
uchar Read_Int;
Clr_P25; //使能控制。為低電平時(shí),并行數(shù)據(jù)進(jìn)入鎖存器
Clr_P25;
Read_Int = (P2 & 0x10); //串行輸出數(shù)據(jù)線
if(Read_Int == 0x10) //把最高位讀出
receive_date |=0x01;
Clr_P03;
Set_P25; //為高電平時(shí),可以進(jìn)行串行數(shù)據(jù)讀出
for(i=1;i<=7;i++) //接下來只要進(jìn)行7次循環(huán)
{
Clr_P03;
Set_P03; //時(shí)鐘線,上升沿有效
Read_Int = (P2 & 0x10); //串行輸出數(shù)據(jù)線
if(Read_Int == 0x10)
{
receive_date |=(0x01<<i);
}
}
return receive_date;
}
|