Skip to main content
etour.1
Associate II
May 4, 2023
Solved

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);

 }

 

 

 

 

This topic has been closed for replies.
etour.1
etour.1Best answer
Associate II
May 17, 2023

cleanup seems to solve the problem once I update

ee_status=

to

ee_status|=

thanks

12 replies

Chloe Meunier
ST Employee
May 10, 2023

You also have to check if a cleanup is required . XCUBE-EEPROM firmware provide a code example to store 1000 times 3 variables :

 /* Store 1000 values of Variable1,2,3 in EEPROM */

 for (VarValue = 1; VarValue <= 1000; VarValue++)

 {

  while (ErasingOnGoing == 1) { }

  ee_status = EE_WriteVariable32bits(1, VarValue);

  ee_status|= EE_ReadVariable32bits(1, &a_VarDataTab[0]);

  if (VarValue != a_VarDataTab[0]) {Error_Handler();}

  ee_status|= EE_WriteVariable32bits(2, ~VarValue);

  ee_status|= EE_ReadVariable32bits(2, &a_VarDataTab[1]);

  if (~VarValue != a_VarDataTab[1]) {Error_Handler();}

  ee_status|= EE_WriteVariable32bits(3, VarValue << 1);

  ee_status|= EE_ReadVariable32bits(3, &a_VarDataTab[2]);

  if ((VarValue << 1) != a_VarDataTab[2]) {Error_Handler();}

  /* Start cleanup polling mode, if cleanup is needed */

  if ((ee_status & EE_STATUSMASK_CLEANUP) == EE_STATUSMASK_CLEANUP) {ErasingOnGoing = 0;ee_status|= EE_CleanUp();}

  if ((ee_status & EE_STATUSMASK_ERROR) == EE_STATUSMASK_ERROR) {Error_Handler();}

 }

BR

Chloé

etour.1
etour.1AuthorBest answer
Associate II
May 17, 2023

cleanup seems to solve the problem once I update

ee_status=

to

ee_status|=

thanks