cancel
Showing results for 
Search instead for 
Did you mean: 

Error in FW-Library example - write over eeprom page

pt1
Associate II
Posted on June 28, 2009 at 11:08

Error in FW-Library example - write over eeprom page

1 REPLY 1
pt1
Associate II
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 ]