IIc的问题

2019-08-13 21:33发布


u8 AT24cxx_ReadOneByte(u16 ReadAddr)
{
u8 temp=0;                          
    IIC_Star();  
if(EE_TYPE>AT24C16)//#define EE_TYPE AT24C02  #define AT24C02 255  #define AT24C16  2047
{
  IIC_Sendbyte(0XA0);   
  IIC_wait_ACK();
  IIC_Sendbyte(ReadAddr>>8);
  IIC_wait_ACK();   
}else IIC_Sendbyte(0XA0+((ReadAddr/256)<<1));   
IIC_wait_ACK();
    IIC_Sendbyte(ReadAddr%256);   
IIC_wait_ACK();     
IIC_Star();        
IIC_Sendbyte(0XA1);            
IIC_wait_ACK();  
    temp=IIC_Readbyte(0);     
    IIC_Stop();//   
return temp;
}
这是原子哥的程序,鉴于使用的是24c02,因此我就这样简单写了

u8 temp;
//&Iuml;&Egrave;&ETH;&acute;
IIC_Star();
delay_us(2);
IIC_Sendbyte(0XA0);//send×&acute;&Igrave;&not;&Ograve;&sup2;&frac34;&Iacute;&Ecirc;&Ccedil;&pound;&not;IO&iquest;&Uacute;&Icirc;&ordf;&Ecirc;&auml;&sup3;&ouml;×&acute;&Igrave;&not;
IIC_wait_ACK();
//&Ocirc;&Uacute;&para;&Aacute;
IIC_Star();
IIC_Sendbyte(0XA1);//send×&acute;&Igrave;&not;&Ograve;&sup2;&frac34;&Iacute;&Ecirc;&Ccedil;&pound;&not;IO&iquest;&Uacute;&Icirc;&ordf;&Ecirc;&auml;&sup3;&ouml;×&acute;&Igrave;&not;
IIC_wait_ACK(); //
temp=IIC_Readbyte(0);
IIC_Stop();
delay_ms(5);
return temp;
但是行不通,不知道是哪里少了什么环节吗?
求大神解惑

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
1条回答
烽烟愠梓
2019-08-13 23:17
        u8 temp;
       
        IIC_Star();
        delay_us(2);
        IIC_Sendbyte(0XA0);//
        IIC_wait_ACK();
       
        IIC_Star();
        IIC_Sendbyte(0XA1);//
        IIC_wait_ACK();        //
        temp=IIC_Readbyte(0);
        IIC_Stop();
        delay_ms(5);
        return temp;
那个有点乱,大神看这个吧,发的时候没注意不好意思

一周热门 更多>