本帖最后由 eveloves 于 2017-4-1 19:56 编辑
74HC597只能读第一个芯片,第二个芯片就无法读取!!!!
#include <reg51.h>
#include <intrins.h>
typedef unsigned char u8 ;
typedef unsigned int u16 ;
sbit PL = P3^7;
sbit SHCP = P3^6;
sbit SO = P3^5;
u16 Read_74hc579()
{
u8 i = 0;
u16 read_data = 0;
PL = 0; _nop_();
PL = 1; _nop_();
for(i=0; i<16; i++)
{
read_data <<= 1;
if(SO) read_data |= SO;
SHCP = 0; _nop_();
SHCP = 1; _nop_();
}
return read_data;
}
void main()
{
u16 temp = 0;
u8 *pos = (u8*)(&temp);
while(1)
{
temp = Read_74hc579();
P1 = pos[0];
P2 = pos[1];
}
}
|