cancel
Showing results for 
Search instead for 
Did you mean: 

BUG in eeprom example code

lior
Associate II
Posted on May 13, 2008 at 10:40

BUG in eeprom example code

1 REPLY 1
lior
Associate II
Posted on May 17, 2011 at 12:23

hello,

i think there is a bug in eeprom.c file.

when i tried to write to same address data that cn be return the write function doesnt write it.

for example:

first write : data :6 virtual address :0xaaaa

second write : data :8 virtual address :0xaaaa

third write : data :6 virtual address :0xaaaa

the last write will not be executed and when i will read the data

form the virtual address 0xaaaa i get 8 instead of 6.

the problem is in this function ''u16 EE_VerifyPageFullWriteVariable(u16 VirtAddress, u16 Data)''

the problem happen because of these lines:

/* Check each active page address starting from begining */

while (Address < PageEndAddress)

{

/* Verify each time if Address and Address+2 contents are equal to Data and VirtAddress respectively */

if (((*(vu16*)Address) == Data) && ((*(vu16*)(Address + 2)) ==VirtAddress))

{

return FLASH_COMPLETE;

}

the problem that in the function there are 2 lines that check if the data and the virtual address already exist in order not to write twice the same data but they do this for all the store data from the beginning address and not form the last addres so if they find the data in the beginning they retun from the function.