標題: 單片機驅(qū)動74hc165程序+電路圖(并轉(zhuǎn)串) [打印本頁]

作者: daming    時間: 2014-12-30 00:55
標題: 單片機驅(qū)動74hc165程序+電路圖(并轉(zhuǎn)串)

當1腳拉低時,八位并行數(shù)據(jù)被壓入鎖存器,但與此同時,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ù)據(jù)進入鎖存器
        Clr_P25;
        
         Read_Int = (P2 & 0x10);  //串行輸出數(shù)據(jù)線
         if(Read_Int == 0x10)     //把最高位讀出
          receive_date |=0x01;
         
         
        Clr_P03;
        Set_P25;     //為高電平時,可以進行串行數(shù)據(jù)讀出
        for(i=1;i<=7;i++)       //接下來只要進行7次循環(huán)
        {
               Clr_P03;   
               Set_P03;   //時鐘線,上升沿有效
               Read_Int = (P2 & 0x10);  //串行輸出數(shù)據(jù)線              
               if(Read_Int == 0x10)
               {  
                     receive_date |=(0x01<<i);
                }
          }
          return   receive_date;
}






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1