FLASH_DRV_SetFlexRamFunction for query

cancel
Showing results for 
Search instead for 
Did you mean: 

FLASH_DRV_SetFlexRamFunction for query

276 Views
Contributor II

hello,

   when i used FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_STATUS_QUERY, 0x00u, &status)  to check the sectorEraseCount, but always equal 0,  the test code is as the following, 

typedef struct
{
uint8_t brownOutCode; /*!< Brown-out detection code */
uint16_t numOfRecordReqMaintain; /*!< Number of EEPROM quick write records requiring maintenance */
uint16_t sectorEraseCount; /*!< EEPROM sector erase count */
} flash_eeprom_status_t;

if (flashSSDConfig.EEESize == 0u)
{
ret = FLASH_DRV_DEFlashPartition(&flashSSDConfig, 0x02u, 0x08u, 0x0u, false, true);
DEV_ASSERT(STATUS_SUCCESS == ret);

/* Re-initialize the driver to update the new EEPROM configuration */
ret = FLASH_DRV_Init(&Flash_InitConfig0, &flashSSDConfig);
DEV_ASSERT(STATUS_SUCCESS == ret);

/* Make FlexRAM available for EEPROM */
ret = FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_ENABLE, 0x00u, NULL);
DEV_ASSERT(STATUS_SUCCESS == ret);
}
else
{
/* Make FlexRAM available for EEPROM, make sure that FlexNVM and FlexRAM
* are already partitioned successfully before */
ret = FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_ENABLE, 0x00u, NULL);
DEV_ASSERT(STATUS_SUCCESS == ret);
}

#define EEPROM_START_ADDR 0x14000000u
uint32_t InitData = 0xFFFFFFFF;

flash_eeprom_status_t status = {0};

ret = FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_STATUS_QUERY, 0x00u, &status);
DEV_ASSERT(STATUS_SUCCESS == ret);
ret = FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_ENABLE, 0x00u, NULL);
DEV_ASSERT(STATUS_SUCCESS == ret);

for(i=0; i<1024; i++)
{
       FLASH_DRV_EEEWrite(&flashSSDConfig, EEPROM_START_ADDR + i*4, 4, (uint8_t *)&InitData);
}
FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_STATUS_QUERY, 0x00u, &status);

My  question is why status.sectorEraseCount is always equal 0? 

What's the use of this data(sectorEraseCount )?

when will this variable increase itself?

wish your help, thanks  in advance!

0 Kudos
8 Replies

146 Views
NXP TechSupport
NXP TechSupport

Hello,

This variable is increased when the EEPROM state machine erases sectors.
However, sectors are erased when there is no space left.

Best regards,

Diana

0 Kudos

146 Views
Contributor II

hello Diana,

what's the use of this variable (sectorEraseCount), and whether does this variable value will be cleared when reset ?

0 Kudos

146 Views
NXP TechSupport
NXP TechSupport

Hello,

"what's the use of this variable (sectorEraseCount)"

Informative. If you want to no more about "EEPROM quick write status query", please, refer to the RM rev 12.1

"Table 36-70. Set FlexRAM Function command FCCOB requirements" or AN11983 can be useful.

https://www.nxp.com/docs/en/application-note/AN11983.pdf 

When the FlexRAM Function Control Code is 0x77, after clearing the EEERDY flag, the
emulated EEPROM system will be interrogated, and EEPROM cleanup requirements and
EEPROM sector erase count will be reported.

"whether does this variable value will be cleared when reset ?"

No, it won't be cleared after reset.

I hope it helps.

Best Regards,

Diana

0 Kudos

146 Views
Contributor II

hello, 

      The sector erase count  is more than 3 when i last test、but when i update the test code  the SectorEraseCount increase form 0 to three, why it can be cleared and i don't know howto clear it

pastedImage_1.png

0 Kudos

146 Views
NXP TechSupport
NXP TechSupport

Hello,

When you update code which means that you load a new application project into MCU the previous configuration (application) is erased including partitioning. So, when there is no partitioning, there is no information about the previous EEPROM erase sectors. 

Note: The partition is supposed to be done only once during the application lifetime.

Best regards,

Diana

0 Kudos

146 Views
Contributor II

hello,

   How to avoid the partition information erased when update the code with S32K  DS?   and  does the erase counter will increase 1 if i write 4097(flexRAM size is 4096 bytes) bytes to flexSRAM?

0 Kudos

146 Views
NXP TechSupport
NXP TechSupport

Hello,

1. I would like to ask you. Why do you need to update code while you want to keep EEPROM data? What do you need to update?

2.

Let's say that you have 64KB EEPROM backup size and 4KB FlexRAM. You can write 8x whole FLexRAM before erase.

The Flex Memory Endurance Calculator will help you with the calculation.
https://www.nxp.com/downloads/en/calculators/FME-Calculator.zip

I hope it helps.

Best regards,

Diana

0 Kudos

146 Views
Contributor II

hello, when will this variable(sectorEraseCount) will be cleared?  for example can parttiton caommand  will clear it ?  or it is save all  the  MCU's life?

0 Kudos