| 
 
| unsigned char DS_ReadByte(void) {
 volatile unsigned char presen;
 unsigned char i=0;
 volatile unsigned char temp=0;
 
 for (i=0;i<8;i++)
 {
 temp=temp>>1; //右移位等待接收一位数据
 
 Delay_short(2);   //延时3us
 P0DIR=0xff;//输出方式
 DQ = 0;               //给脉冲信号
 Delay_short(3);   //延时4us
 P0DIR=0xfd;//输入方式
 Delay_short(7);   //延时8us
 presen = P0;
 presen =presen&0x02;
 
 if(presen == 0x02)  //从低位开始接收数据
 {
 temp|=0x80;
 countflag= countflag+1;
 }
 Delay_short(20);   //延时21us
 Delay_short(20);   //等待复位延时21us
 P0DIR=0xfd;           //拉升电压
 Delay_short(25);   //延时26us
 }
 return(temp);
 }
 如果前面一次判断if不符合的话,而这次符合if的话会写成11,而不是01
 ,怎么回事情呀
 | 
 |