Skip to main content
Associate
July 6, 2023
Question

Not able to write a complete page in 256 K-Bit I2C EEPROM

  • July 6, 2023
  • 2 replies
  • 1778 views

I am using M24256-BW M24256-BR M24256-BF
M24256-DR M24256-DF 256 K-Bit I2C EEPROM for booting purpose.
While writing the data into EEPROM, I am not able to write the last byte(64th) of the page.
If I will write it separately, then it will work fine but with the page write it is not.

Is there any workaround for this issue.
I am following the correct sequence of steps given in the datsheet.

Thank you.

 

This topic has been closed for replies.

2 replies

TDK
Super User
July 6, 2023

Perhaps the indices are 0-based and you're using 1-based. Show you code.

"If you feel a post has answered your question, please click ""Accept as Solution""."
msjk25Author
Associate
July 7, 2023

I am using 0 based indices only.
If I am writing 65 bytes, then also what is happening is the last byte is rolling over to 0th index but the last byte remains same as FF. (the 64th byte is not getting written anywhere).

My write function is as below:

void drv_writeEeprom(UINT32 count, UINT16 w_addr, UINT8* i2cDataSendArray){

 

    /*Give the start condition*/
    i2c_start(M_APPI2C_REGS_PTR);

    /*Send slave address with R/W_ bit as 0*/
    drv_i2cSendData(M_APPI2C_REGS_PTR,0xA0U);

    /*Send the two bytes of address*/
    drv_i2cSendData(M_APPI2C_REGS_PTR,w_addr>>8);
    drv_i2cSendData(M_APPI2C_REGS_PTR,w_addr & 0xFFU);

    /*Send the data bytes to write in EEPROM*/
    for(UINT32 i=0;i<count;i++){
        drv_i2cSendData(M_APPI2C_REGS_PTR,i);
    }

    /*Give the stop condition*/
    i2c_stop(M_APPI2C_REGS_PTR);

    /*Give a delay of 5ms for internal write cycle to be completed*/
    sys_delayInUs(5000);

}

 

Tesla DeLorean
Guru
July 7, 2023

And what platform is this?

Perhaps inspect signals with a scope or logic analyzer, looking specifically how it manages the stop. How the stop and start functions wrap the drv_i2c function. Perhaps there are other more compound functions.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
TDK
Super User
July 9, 2023

> If I am writing 65 bytes,

You can only write one page (64 bytes) at a time, per the datasheet. If your first written index is 0, then the last written index will be 63, not 64.

TDK_0-1688862632630.png

 

"If you feel a post has answered your question, please click ""Accept as Solution""."