请大家帮我看看,用的是PROTEUS跟52的开发板验证的,结果一样。其中addr=0xA0,addr_dat=0xAA或0xAB,ReadBytes=8.
unsigned char ReadContinuously(addr,addr_dat,ReadBytes)
{
Start();
Write(addr);
Write(addr_dat);
Start();
Write(addr+1);
for(;ReadBytes>0;ReadBytes--)
{
for(BIT=8;BIT>0;BIT--)
{
ReadDat<<=1;
ReadDat|=SDA;
SCL=1;
_nop_;
SCL=0;
}
if(ReadBytes==1)
SDA=1;
else SDA=0;
SCL=1;
SCL=0;
}
Stop();
}
|