EEPROM blocked while page change
Hi ST community,
First question for me here.... It is about an emulated eeprom issue
I try to save dta to an emulated eeprom.
Parameter are : starting dress : 0x800D00
page size 0x800
number of variable to be saved 37
guard page number =2
cycle life =1
I do manage to save and read from eeprom however, after a while (let's say between 500 and 1000 saving operations, the eeprom comes into the loop below and don't mnage to get out...
Would somebody knows why ? I assume my parameters are wrong but I can't figure it out ...
Thanks ,
Tjhe loop that blocks ...
pageadress takes the value 28 27 26 and then back to 28.
while ((pagestate == STATE_PAGE_ACTIVE) || (pagestate == STATE_PAGE_VALID) || (pagestate == STATE_PAGE_ERASING))
{
/* Set counter index to last element position in the page */
counter = PAGE_SIZE - EE_ELEMENT_SIZE;
/* Check each page address starting from end */
while (counter >= PAGE_HEADER_SIZE)
{
/* Get the current location content to be compared with virtual address */
addressvalue = (*(__IO EE_ELEMENT_TYPE*)(pageaddress + counter));
if (addressvalue != EE_PAGESTAT_ERASED)
{
/* Compare the read address with the virtual address */
if (EE_VIRTUALADDRESS_VALUE(addressvalue) == VirtAddress)
{
/* Calculate crc of variable data and virtual address */
crc = CalculateCrc(EE_DATA_VALUE(addressvalue), EE_VIRTUALADDRESS_VALUE(addressvalue));
/* if crc verification pass, data is correct and is returned.
if crc verification fails, data is corrupted and has to be skip */
if (crc == EE_CRC_VALUE(addressvalue))
{
/* Get content of variable value */
*pData = EE_DATA_VALUE(addressvalue);
return EE_OK;
}
}
}
/* Next address location */
counter -= EE_ELEMENT_SIZE;
}
/* Decrement page index circularly, among pages allocated to eeprom emulation */
page = PREVIOUS_PAGE(page);
pageaddress = PAGE_ADDRESS(page);
pagestate = GetPageState(pageaddress);
}
