SuperIC社区_

标题: 【Monitor】大容量EEPROM与小容量EEPROM读写方面的区别(主要... [打印本页]

作者: zz.wang    时间: 2016-5-30 16:45
标题: 【Monitor】大容量EEPROM与小容量EEPROM读写方面的区别(主要...
24C16及以下的EEPROM每次要发送8位的存储地址,而24C32以上的EEPROM需要发送16位的存储地址,,所以,如果外部控制程序不变的话,两个芯片是不可以互换的,需要在程序做相应的区分。附件是24C16与24C256的时序区别:

作者: zz.wang    时间: 2016-5-30 16:46
由于程序比较大,我简单的介绍一下两个的区别(主要是红色部分的区别):
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;
}

作者: 一点蓝    时间: 2016-6-1 14:42
好专业的资料,学习下




欢迎光临 SuperIC社区_ (/) Powered by Discuz! X3.3