This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SN74HC166: 关于SN74HC166芯片开发读取数据错乱的时序问题

Part Number: SN74HC166

开发SN74HC166芯片时,读取到的数据是错乱的,以下是我的相关代码。    开发中,只需要控制CLK(PG14),SH/LD(PG11),QH(PB3)三个引脚,其余引脚已经通过硬件设计处理好了, 

//

uint8_t    SN74HC166_data()

{

   uint8_t   data = 0;

  uint8_t    i =0;

GPIO_writeBit(GPIOG,GPIO_Pin_11,Bit_RESET);     //将并行数据传入移位寄存器

//生成锁存时钟

GPIO_writeBit(GPIOG,GPIO_Pin_14,Bit_RESET);

GPIO_writeBit(GPIOG,GPIO_Pin_14,Bit_SET);

GPIO_writeBit(GPIOG,GPIO_Pin_11,Bit_SET);   //进入串行模式

for(i=0;   i<8;   i++)

{

     if(GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3))

       {

             data | = 1<<i ;

         }

    else;

GPIO_writeBit(GPIOG,GPIO_Pin_14,Bit_RESET);

GPIO_writeBit(GPIOG,GPIO_Pin_14,Bit_SET);

}

return  data;

}