Hello~all
I would like to ask some questions about debugging SN74HC165.
The program is so easy and there are many examples in the internet. I have debuged it two days after board-making. I don’t know why it still cannot read data out and always keep 0xFF. The wave which I detect it by oscilloscope is normal. When program is ready to install into the inside register of HX165 as well as shifting out,but why the data can’t be read out?
The SN74HC165 PDF: www.kynix.com/uploadfiles/pdf8798/SN74HC165D.pdf
My program is as following:
void HC_74165Init(void){
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD, ENABLE);
//HC165 CLK //HC165 SH
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_11;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_Init(GPIOD, &GPIO_InitStructure);
//HC-SO
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_8;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode =GPIO_Mode_IPD; ; //GPIO_Mode_IPU;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
u8 Read_HC165(void)
{
u8 i;
u8 Byte=0;
u8 Data=0;
SHLD_165=0;//The external port data into internal registers
delay_nus(100);
SHLD_165=1; //ready to shift
delay_nus(100);
CLK_165=1;
for(i=0;i<8;i++)
{
Byte<<=1;
Data=GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_8);
printf("%X ",Data);
Byte|=Data;
CLK_165=0;
delay_nus(5000);
CLK_165=1;
}
return Byte;
}
Image Insert:
89452 bytes
Image Insert:
7585 bytes
Image Insert:
8337 bytes