cancel
Showing results for 
Search instead for 
Did you mean: 

EEPROM blocked while page change

etour.1
Associate II

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

 }

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
etour.1
Associate II

cleanup seems to solve the problem once I update

ee_status=

to

ee_status|=

thanks

View solution in original post

12 REPLIES 12
Chloe Meunier
ST Employee

Hello,

Could you please tell me on which device you are working please and show your applicative code?

etour.1
Associate II

hi, Thanks for your answer : the uC is an stm32G071

typical application code looks like this :

EE_WriteVariable16bits((int *)cAddr_cusaR0Mes     , usa_Temp[0]);

EE_WriteVariable16bits((int *)cAddr_cusaR0E0      , usa_Temp[1]);

EE_WriteVariable16bits((int *)cAddr_cusaR0EM      , usa_Temp[2]);

EE_WriteVariable16bits((int *)cAddr_cusaR0CapTequ   , usa_Temp[3]);

EE_WriteVariable16bits((int *)cAddr_cusaR0CapConso   , usa_Temp[4]);

EE_WriteVariable16bits((int *)cAddr_cusaR0Ibat     , usa_Temp[5]);

EE_WriteVariable16bits((int *)cAddr_cusaR0Ubat     , usa_Temp[6]);

EE_WriteVariable16bits((int *)cAddr_cusaR0State    , usa_Temp[7]);

EE_WriteVariable16bits((int *)cAddr_cusaCodeBatModeAlrm, usa_Temp[8]);

Chloe Meunier
ST Employee

Perhaps you could make a trial with a starting address @ 0x0801 0000 ?

Are you sure your flash is free@ 0x0800D000?

etour.1
Associate II

yes it is free down to 0x0800C000

Chloe Meunier
ST Employee

Ok if you can try to change the starting address @ 0x0801 0000 to check it's not the problem..

etour.1
Associate II

I will and I let you know

etour.1
Associate II

Hi Chloe,

There isn't actually enough space between 0x8010 0000 and the end of the flash to be able to load all pages ...

(indeed) I got error message while loading with this parameter :

"Break at address "0xfffffffe" with no debug information available, or outside of program code."

Edgar

Chloe Meunier
ST Employee

Hello Edgar,

Yes I wrote  @ 0x0801 0000 not 0x8010 000 :)

etour.1
Associate II

Sorry, I did write it wrong. Indeed, I used 0x0801 0000 and got this error not 0x8010 0000

//#define START_PAGE_ADDRESS   0x08010000U /*!< Start address of the 1st page in flash, for EEPROM emulation */

#define START_PAGE_ADDRESS    0x0800C800U /*!< Start address of the 1st page in flash, for EEPROM emulation */

#define CYCLES_NUMBER      1U  /*!< Number of 10Kcycles requested, minimum 1 for 10Kcycles (default),

                    for instance 10 to reach 100Kcycles. This factor will increase

                    pages number */

#define GUARD_PAGES_NUMBER   2U  /*!< Number of guard pages avoiding frequent transfers (must be multiple of 2): 0,2,4.. */