S32K144 EEPROM sector erase count

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K144 EEPROM sector erase count

1,677 Views
maciej_cebula
Contributor II

Hi all,
I am using S32K144 in my project, now I'm implementing EEPROM functionality and all is working fine, but now I want to add some extra feature such as: detected the power loss, or calculation the endurance of the EEPROM in the code.
I am not using quick write functionality - only standard.

For this purpose, I'm reading the FlexRAM Function command FCCOB, below there is my code it is base on the example from S32 Studio.
My problem here is that all-time I got 0 in Brown-out (BO) Detection Codes and in EEPROM sector erase count. Even if the power loss is observed in the data reading from backup EFlash because they are initialized with 0xFF. Can you give me some hint?

Std_Return_t Flash_SetFlexRamFunction( FlexRamFunctionControlCode_t tFlexRamFuncCode,  NvmStatus_t * const psNvmStatus)
{
 Std_Return_t tResult = STD_OK;
 /* Check CCIF to verify the previous command is completed */
 if (0U == (FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK))
 {
  tResult = STD_BUSY;
 }
    else
    {
        /* Clear RDCOLERR & ACCERR & FPVIOL flag in flash status register. Write 1 to clear */
     FTFC->FSTAT = (uint8)(FTFC_FSTAT_FPVIOL_MASK | FTFC_FSTAT_ACCERR_MASK | FTFC_FSTAT_RDCOLERR_MASK);
        /* Passing parameter to the command */
  FTFC->FCCOB[FLASH_FCCOB0_INDEX] = FLASH_FCMD_SET_EERAM;
  FTFC->FCCOB[FLASH_FCCOB1_INDEX] = (uint8_t)tFlexRamFuncCode;

        /* Calling flash command sequence function to execute the command */
        DISABLE_IRQ();
  tResult = Fls_CommandSequence();
  ENABLE_IRQ();

        if ((tFlexRamFuncCode == EEE_STATUS_QUERY) && (tResult == STD_OK))
        {
            if (psNvmStatus == 0u)
            {
             tResult = STD_NOT_OK;
            }
            else
            {
                psNvmStatus->u8BrownOutCode = FTFC->FCCOB[FLASH_FCCOB5_INDEX];
                psNvmStatus->u16SectorEraseCount = (uint16_t)((uint16_t)FTFC->FCCOB[FLASH_FCCOB8_INDEX] << 8U);
                psNvmStatus->u16SectorEraseCount |= (uint16_t)FTFC->FCCOB[FLASH_FCCOB9_INDEX];
            }
        }
    }
    return tResult;
}
0 Kudos
4 Replies

1,378 Views
veerajuvh619
Contributor III

Hi sir,

Ian using S32K144 I made partition of flash memory 4kB as EEE Memory and 64kb of flex-NVM.

I used this for sector erase but it's showing status error.

address = flashSSDConfig.DFlashBase;
size = FEATURE_FLS_DF_BLOCK_SECTOR_SIZE;
ret = FLASH_DRV_EraseSector(&flashSSDConfig, address, size);
DEV_ASSERT(STATUS_SUCCESS == ret);

Please help me to erase eeprom sector

Regards,

Veeraju V Hallikeri

0 Kudos

1,378 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Is the EERRDY flag set after POR?

 pastedImage_1.png

How many records have you written to the FlexRAM that you expect erased EEPROM backup sectors?

The EEPROM state machine erases sectors when there is no place left only.

BR, Daniel

0 Kudos

1,378 Views
maciej_cebula
Contributor II

Hi, 
1. EERRDY flag is set after POR. I have a similar algorithm like in flow chart above and it is all time return 0.

2. Thanks for the hint, yesterday I did not enough write to the FlexRam, today I did more, and it returns correctly the number of erasing. Here is my question what is the best way to calculate lifetime for EEPROM? I know that is the dedicated application for this FlexMEmory Endurance Calculator but to me, it is not clear how I can move result from there to the code, that I can in runtime calculate the used of EEPROM.  

0 Kudos

1,378 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Maciej,

I'm sorry for the delay.

The Brown-out (BO) detection code depends on the moment when the reset occurs while there is a write in progress.

Please note that the CCIF flag indicates that a command is in progress from the Flash Controller perspective, so that no other commands can be triggered, but the EEPROM state machine has its own timing. If resetting too early, there is no interrupted EEPROM write and the EEPROM simply retains the last valid written record.

You can try delaying the reset.

The FlexMemory Endurance calculator calculates the number of estimated erase cycles on EEPROM backup based on the partition and application requirements. The application can get the number of erase cycles using the EEPROM status query command. 

BR, Daniel

0 Kudos