|
我是看了许多次单片机视频后,自己写程序,下面是我自己都芯片手册的疑惑。在读时序中,数据手册上有这样一句:A read time slot is initiated by the master device pulling the 1-Wire bus low for a minimum of 1μs and then releasing the bus 。
for(j=8; j>0; j--)
{
DSPORT = 0;
i++;
DSPORT = 1;
i++;
i++
bi = DSPORT;
byte = (byte >> 1) | (bi << 7);
i = 4;
while(i--);
}
在写时序中,数据手册上有这样一句:To generate a Write 1 time slot, after pulling the 1-Wire bus low, the bus master must release the 1-Wire bus within 15μs.
for(j=0; j<8; j++)
{
DSPORT = 0;
i++;
DSPORT = dat & 0x01;
i=6;
while(i--)
DSPORT = 1;
dat >>= 1;
}
按着我的理解是:在写时序的时候先DSPORT = 0;接着DSPORT = 1; 我的理由一个是数据手册要求释放总线,(应该就是拉高吧),第二个理由感觉写时序的说法和读时序一样,所以写的顺序应该一样啊。
如果是完全按着时序图来,写时序可以解释的通,但是读时序又有问题,感觉在DSPORT = 0;就不必紧跟着DSPORT = 1;
!!!!!!!!不要忽悠,谢谢!!!!!!!!!!!!!!!
[color=rgba(0, 0, 0, 0.541176)]122/5000
|
|