亚洲春色中文字幕久久久-三上亚,一吻二脱三床四吻胸,国产真实伦对白视频全集,在线毛片观看,精品成品入口黄网,国产毛aⅴ片久久久,亚洲AV色香蕉一区二区三区老师,萧皇后A级艳片,色情日本视频更新,99久久亚洲精品日本无码

標(biāo)題: 求助 DS1302讀出來的數(shù)據(jù)亂碼 [打印本頁]

作者: nivans    時間: 2015-9-1 12:30
標(biāo)題: 求助 DS1302讀出來的數(shù)據(jù)亂碼
/*---------------------------------------------
/* DS1302 Read Byte
/*-------------------------------------------*/
uint8 ReadByte()
{
uint8 i,tmp = 0x00;

for(i = 0; i < 8 ; i ++)
  {  
   
    if(io) tmp|=0x80;
    sclk = 1 ;
    tmp >>= 1;
   sclk = 0;
  }
  return tmp;
  
}
/*---------------------------------------------
  DS1302 WriteByte()
--------------------------------------------*/
void WriteByte(uint8 dat)
{
uint8 i;

   for(i = 0; i < 8 ; i ++)
   {
   io = (bit)(dat & 0x01);
    dat >>= 1;
    sclk = 1;
   sclk = 0;
   }
   
}
/*---------------------------------------------
/* DS1302 SingleRead
/*-------------------------------------------*/
uint8 SingleRead(uint8 addr)
{
   uint8 tmp;

  cs = 1;
   _nop_();
   WriteByte(addr);
   tmp = ReadByte();
   cs = 0;
return tmp;
}
/*----------------------------------------------
/* DS1302 SingleWrite
/---------------------------------------------*/
void SingleWrite(uint8 addr,uint8 dat)
{
  cs = 1;
   WriteByte(addr);
   WriteByte(dat);
   cs = 0;
}

SingleRead函數(shù)寫入的的地址沒問題,讀出的數(shù)據(jù)是錯的。
請高手幫忙看一下,哪里錯了?

作者: WYY1032829355    時間: 2016-2-17 14:27
同學(xué),你的ReadByte()函數(shù)有問題,循環(huán)8次,所以右移8次,出問題。比如數(shù)據(jù)1000  0000,然后讀取最高位時候tem=1000 0000,然后右移一位了,此時變成了0100  0000 了




歡迎光臨 (http://www.denmoz.com/bbs/) Powered by Discuz! X3.1