Skip to main content
pt1
Associate III
June 28, 2009
Question

Error in FW-Library example - write over eeprom page

  • June 28, 2009
  • 1 reply
  • 566 views
Posted on June 28, 2009 at 11:08

Error in FW-Library example - write over eeprom page

    This topic has been closed for replies.

    1 reply

    pt1
    pt1Author
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:16

    Hi,

    it seems that I have found an error in the I2C eeprom example:

    ...

    void EE_BufferWrite(u8* pBuffer, u16 WriteAddr, u16 NumByteToWrite)

    {

    u8 NumOfPage = 0, NumOfSingle = 0, Addr = 0, count = 0;

    Addr = WriteAddr % EE_PageSize;

    count = EE_PageSize - Addr;

    NumOfPage = NumByteToWrite / EE_PageSize; // ERROR this is not sufficient

    // added code start ... ############################################

    if((NumByteToWrite < EE_PageSize) && ((Addr+NumByteToWrite) > EE_PageSize)) NumOfPage++;

    // ###############################################... added code end

    NumOfSingle = NumByteToWrite % EE_PageSize;

    ...

    The problem was that I have to write less than page bytes over a page border. With the added lines it seems to works correctly. Hope it is useful for someone.

    Best regards

    [ This message was edited by: pt1 on 28-06-2009 14:40 ]

    [ This message was edited by: pt1 on 28-06-2009 14:40 ]