Data flash memory is erasing occassionally

Hi Renesas team,

I am using rl78 r5f102aa microcontroller and its data flash to store some settings in it.

In my product I am using 3.7v battery backup (2400mah), when power interruption happens, the mcu should run with battery backup.

Now, the problem is, the stored settings in data flash is erasing sometimes. I thought the issue is because of the writing/reading happens during battery powered. So I stopped memory operations during power interruption (battery time). Still the same issue observed.

Now, I started writing the settings in two different banks in data flash as extra data backup. I am not sure whether it will resolve the issue.

I want to know the reason for erasing and if the erase happens, will it erase complete data flash (second block) too, which I am using as extra second back up.

Please suggest.

Thanks

Manjunath

  • Good day, manju!

    How are things going for you? Have you observed when this likely to happen or it just happened randomly? I hope you could wait for responses from the experts on RL78. Thank you.

    Best regards,
    Sai
    RenesasRulz Forum Moderator

    https://renesasrulz.com/
    https://academy.renesas.com/
    en-us.knowledgebase.renesas.com/
  • In reply to Sai:

    Hi Sai,

    Thanks for the response.

    The issue is observed randomly - weekly/monthly once. I am reading the dataflash stored parameters at the beginning of the main function after the peripherals and dataflash initialization.

    Thanks
    Manju
  • In reply to manju:

    The data-flash cannot be erased without initiating a self-programming operation on the block. Are you using the Tiny / T02 EEL or just FDL in your code? EEL is designed to be reset resistant and implement wear-leveling. If using only FDL you must implement your own strategy for both concepts to maintain data integrity.

  • Thanks for the response.

    I am using FDL library and the following APIs

    1. For write operation

    a. R_FDL_Open()
    b. 5 secs delay
    c. If (R_FDL_Erase() == PFDL_OK)
    d. 5 secs delay
    e. If (R_FDL_Write() == PFDL_OK)
    f. 5 secs delay
    g. R_FDL_Close()


    2. For read operation

    a. R_FDL_Open()
    b. 2 secs delay
    c. R_FDL_Read()
    d. 2 secs delay
    e. R_FDL_Close()


    During reading operation, i am not checking return result of R_FDL_Read() and during write operation, executing write function only when I get the return as PFDL_OK from erase function.

    Here am not using R_FDL_Create() and black check functions.

    Now I think I have to implement reset resistant and wear leveling as per your suggestion. I am not understanding this. Please eloberate and guide me how to implement those.

    Thanks
    Manjunath
  • In reply to manju:

    Do you have the documentation for the Renesas FDL and the EEL?

    The users manual for the FDL shows examples of how to use the FDL, I don't understand why you would be executing fixed timing delays, when the library can notify you of the completion of the operation.  For some reason, I don't see the RL78/G12 flash programming times specified in the documentation.  But for other devices which use the same flash process, a block erase operation takes 5ms while a write operation takes 10us.

    Example code for the T02/Tiny FDL can be found in section 4.7 of the FDL U/M R01US0061ED.  The library can be polled for busy status, calling the handler while busy.

    Note that the RL78 data-flash is not like byte-erasable EEPROM.  The erase block size is 1KB while a write unit is 1-byte.  The EEPROM Emulation Library (EEL) uses an approach to implement wear-leveling by performing multiple write operations in a single block, before an erase operation is required.  Reset resistance means that a specific flow is used to ensure the data integrity (e.g. a start marker is first written, followed by the data, followed by an end marker).  Reset resistance also ensures that data is not lost during a block erase operation by duplicating the data in another block before the erase operation is done (Renesas EEL refers to this concept as a "refresh" operation).

    Please refer to the T02/Tiny EEL U/M for more information on the wear-leveling techniques and reset resistant features of the Renesas EEL.

    I would not generally recommend that a user implement their own EEPROM emulation unless they are a very experienced programmer.  If your application has the memory resources available to use the Renesas EEL I would highly recommend that you consider using this off the shelf library.

  • Thanks JB.

    I observed the issue is occurring during erase operation only and voltage drop happening during the same.
    I cannot use eel library as I dont have sufficient memory space.

    I gone through section "2.6 Abortion of commands" in the manual you referred. The function fdl_abort() aborts erase command if the handler is busy and this can be used during voltage drop during erase operation in order to avoid reset of MCU.

    But in FDL library, there is no abort API. Can I implement this function in the FDL erase API so that I want to use abort feature if the erase handler is busy.

    Kindly suggest.

    Thanks
    Manjunath
  • In reply to manju:

    Can you please elaborate on the statement, "But in FDL library, there is no abort API."? If you are using the "Tiny" / T02 FDL this command exists. Or are you using the "Pico" / T04 FDL type? The Pico FDL does not support the abort command.

    Please refer to the Data Flash Access LibraryType T04 (Pico), European Release for the Pico / T04 FDL U/M.

    Perhaps your battery is not able to sustain the power required to perform the erase operation?  If the abort needs to be supported you would have to use the Tiny / T02 FDL.