標(biāo)題: 74hc165不采集數(shù)據(jù),誰(shuí)幫看看什么錯(cuò)誤啊 [打印本頁(yè)]

作者: 835350304    時(shí)間: 2016-5-31 11:45
標(biāo)題: 74hc165不采集數(shù)據(jù),誰(shuí)幫看看什么錯(cuò)誤啊
unsigned int w165(void)
{
           unsigned char base=0;
        unsigned char i;
        unsigned int temp;
        CLK2=0;
        _nop_();_nop_();_nop_();
        PL=1;
        _nop_();_nop_();_nop_();
        PL=0;
        _nop_();_nop_();_nop_();
    PL=1;
        _nop_();_nop_();_nop_();
        base<<=1;
        if(CHK)
        {
                base|=0x01;
        }
       
        for(i=0;i<39;i++)
        {
                CLK=0;
            _nop_();_nop_();_nop_();
                CLK=1;
            _nop_();_nop_();_nop_();
                base<<=1;
                if(CHK)
                {
                    base|=0x01;
                }
        }
    temp=((base&0xff00000000>>16)|(base&0xff000000>>8)|(base&0xff0000)|(base&0xff00<<8)|(base&0xff<<16));

        return temp;
}
void main()
{
   port_mode();
   UART_Init();         
   CLK2=0;
   _nop_();_nop_();_nop_();
   while(1)
   {  
       SBUF=w165();
        Delay1000ms();
   }
}





作者: ahshmj    時(shí)間: 2016-5-31 22:18
你讓他采集什么數(shù)據(jù)?p0~p7上有按鍵?還是有其他的傳感器之類的?
作者: 1013344248    時(shí)間: 2016-6-2 09:42
程序沒(méi)有什么問(wèn)題,檢測(cè)電路連接
作者: 835350304    時(shí)間: 2016-6-2 13:57
謝謝大家,已經(jīng)弄好了
作者: 835350304    時(shí)間: 2016-6-2 13:58
謝謝大家,程序已經(jīng)調(diào)好了
作者: 張三豐    時(shí)間: 2016-6-2 15:59
注意時(shí)序,我記得是要先鎖存,再移位。PL信號(hào)的邊沿鎖存,然后每個(gè)時(shí)鐘邊沿移位一次,從Q7讀數(shù)據(jù)




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