我将CLK引脚接在P0口时,按下独立按键,此时只有第一个和最后一个LED被点亮;当将CLK 引脚接在其他端口时LED显示正常(74LS165模块无短接片)。查看开发板原理图与芯片资料都没问题,请问有大神知道是什么回事吗?
(* ̄▽ ̄)y
下面是源码:
#include"reg52.h"
#include"intrins.h"
#define GPIO_LED P2
typedef unsigned char uchar;
typedef unsigned int uint;
sbit SL=P1^0;
sbit CLK=P3^1;
sbit DATA=P1^2;
uchar _74HC165(void)
{ uchar indata=0;
uchar i;
SL=0;
_nop_(); //????
SL=1;
_nop_(); //??λ for(i=0;i<8;i++)
{
indata=indata<<1;
CLK=0;
_nop_();
indata|=DATA;
CLK=1;
}
return indata;
}
void main()
{
uchar Value;
while(1)
{
Value=_74HC165();
if(Value!=0xff)
{
GPIO_LED=Value;
}
}
}
(* ̄▽ ̄)y
下面是源码:
#include"reg52.h"
#include"intrins.h"
#define GPIO_LED P2
typedef unsigned char uchar;
typedef unsigned int uint;
sbit SL=P1^0;
sbit CLK=P3^1;
sbit DATA=P1^2;
uchar _74HC165(void)
{ uchar indata=0;
uchar i;
SL=0;
_nop_(); //????
SL=1;
_nop_(); //??λ for(i=0;i<8;i++)
{
indata=indata<<1;
CLK=0;
_nop_();
indata|=DATA;
CLK=1;
}
return indata;
}
void main()
{
uchar Value;
while(1)
{
Value=_74HC165();
if(Value!=0xff)
{
GPIO_LED=Value;
}
}
}