This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C2, read 128k EEPROM

It takes 7 seconds to read them all(128K);CLK was observed by the oscilloscope,There is a 1ms delay after each page is read,why?

  • The code is as follows,
    static Int32 I2c_Read(UInt32 i2cNum,
                                   UInt8  slaveAddr,
                                   UInt8 *value, UInt32 count)
    {
        Int32  status      = STW_SOK;
        // uint32_t rawSt;
       UInt32 baseAddress;// = (i2cNum == 0U) ? (SOC_I2C1_BASE) : (SOC_I2C2_BASE);

        switch(i2cNum)
        {
        case BSP_DEVICE_I2C_INST_ID_0:
            baseAddress = SOC_I2C1_BASE;
            break;
        case BSP_DEVICE_I2C_INST_ID_1:
            baseAddress = SOC_I2C2_BASE;
            break;
        case BSP_DEVICE_I2C_INST_ID_2:
            baseAddress = SOC_I2C3_BASE;
            break;
        }

        /* Set the slave address */
        I2CMasterSlaveAddrSet(baseAddress,
                              (UInt32) slaveAddr);

        /* Configure to read (count) data word from the slave register.  */
        I2CSetDataCount(baseAddress, (UInt32) count);

        /*
         * Configure i2c as master-receive and enable.
         * Make sure stop condition is generated after the transaction.
         */  
       
        I2CMasterControl(baseAddress,
                        (UInt32) (I2C_CFG_MST_RX | I2C_CFG_START | I2C_CFG_STOP));
        while(count--)
        {
            /* Read the data if the data is ready. */
            status = SblUtilsI2cCheckXfrStatus(i2cNum, (UInt32) SBL_UTILS_I2C_READ);
     
            if (status == STW_SOK)
            {
                *value = I2CMasterDataGet(baseAddress);
                // rawSt = I2CMasterIntRawStatus(baseAddress);
                // rawSt &= ~(I2C_INT_RECV_READY);
                // I2CMasterIntRawStatusClearEx(baseAddress,rawSt);
            }
            else
            {
                *value = 0U;
            }
            value++;
            /* Wait for I2C access ready before returning. */
            if (status == STW_SOK)
            {
                UInt32 flags = I2C_INT_ADRR_READY_ACESS |
                                I2C_INT_BUS_FREE;
                status = SblUtilsI2cWaitForFlags2(i2cNum, flags);
            }
        }


        /* Clear the status of the I2C  */
        I2CFlushFifo(baseAddress);
        I2CMasterIntClearEx(baseAddress, I2C_INT_ALL);
        I2CSetDataCount(baseAddress, (UInt32) 0U);

        return status;
    }