搜索
 找回密码
 立即注册

简单一步 , 微信登陆

【Monitor】大容量EEPROM与小容量EEPROM读写方面的区别(主要...

查看数: 6391 | 评论数: 2 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2016-5-30 16:45

正文摘要:

24C16及以下的EEPROM每次要发送8位的存储地址,而24C32以上的EEPROM需要发送16位的存储地址,,所以,如果外部控制程序不变的话,两个芯片是不可以互换的,需要在程序做相应的区分。附件是24C16与24C256的时序区别: ...

回复

一点蓝 发表于 2016-6-1 14:42:00
好专业的资料,学习下
zz.wang 发表于 2016-5-30 16:46:35
由于程序比较大,我简单的介绍一下两个的区别(主要是红色部分的区别):
1.小容量发送存储地址的示例程序:

Bool i2c_MasterStart( I2C_Direction direct, BYTE addr )
{
    BYTE retry = 3;

    if( direct == I2C_READ ) // Set I2C direction bit.
        addr |= BIT0;
    else
        addr &= ~BIT0;

    while( retry-- )
    {
        if( i2c_Start() == FALSE )
        {
            i2c_Stop();
            continue;
        }

        if( i2c_SendByte( addr ) == TRUE ) // send address success
            return TRUE;

        i2c_Stop();
        ForceDelay1ms( 2 );
    }
    return FALSE;
}


2.大容量发送存储的示例程序:

Bool i2c_MasterStart( I2C_Direction direct, BYTE addr )
{
    #define NVRAM_DEVICE    0xA0

    BYTE u8Retry=5;
    BYTE addr1 = addr;
    //BYTE u8NvRamID=NVRAM_DEVICE;
    if (direct==I2C_READ) // Set I2C direction bit.
    {
        addr1=NVRAM_DEVICE;// get 0xA0
        addr1|=BIT0;
    }
    else
        addr1&=~BIT0;

    while (u8Retry--)
    {
        if (i2c_Start()==FALSE)
        {
           ForceDelay1ms(1);
            continue;
        }
        if(direct==I2C_READ)
        {
            if (i2c_SendByte(addr1)==TRUE) // send address success
                return TRUE;
        }
        else
        {
            if (i2c_SendByte(NVRAM_DEVICE)==TRUE) // send address success
            {

                if (i2c_SendByte(ucADDR_HI_BYTE)==TRUE) // send address success
                    return TRUE;
            }

        }
        i2c_Stop();
        ForceDelay1ms(2);
    }
    return FALSE;
}
手机版