Skip to main content
JJRR
Associate III
April 4, 2022
Solved

STM32L08xx EEPROM write fail

  • April 4, 2022
  • 2 replies
  • 1758 views

Dear,

on STM32L083 I use internal eeprom. I found out, that when I use function

HAL_FLASHEx_DATAEEPROM_Program

and during execution of this function the power voltage of mcu falls down (uplugged battery from device) - then in eeprom are saved wrong data (probably only in sectors which I wanted to modify by calling the function above).

I use BOR Level1. Also I tried to activate PVD and in its IRQ callbacks I just added while(1); until the mcu goes to reset.

Is there any solution for that?

Thank you very much, Jan.

This topic has been closed for replies.
Best answer by JJRR

Thank you fo reply.

I have already solved it by mirroring the eeprom memory place. Now my value is stored on 3 places in the eeprom - after reading I compare the 3 values and if any 2 are equal then I take them as correct. It cost more memory area, but it seems like it i working.

2 replies

Peter BENSCH
Technical Moderator
April 28, 2022

The problem is that PVD and BOR alone are of no use if the voltage fails at that moment, because the write/erase process must be completed successfully.

Yes, there is a solution: decoupling capacitors with appropriate size to power the STM32L0xx during the full write or erase operation and before the supply voltage goes below the minimum VDD (1.8V with BOR enabled).

Does it answer your question?

Regards

/Peter

JJRR
JJRRAuthorBest answer
Associate III
April 29, 2022

Thank you fo reply.

I have already solved it by mirroring the eeprom memory place. Now my value is stored on 3 places in the eeprom - after reading I compare the 3 values and if any 2 are equal then I take them as correct. It cost more memory area, but it seems like it i working.

Peter BENSCH
Technical Moderator
April 29, 2022

Increasing the size of the buffer capacitors is not an option because that would be the safest method?

Regards

/Peter

JJRR
JJRRAuthor
Associate III
April 29, 2022

I am not sure if I understand. When I add another capacitors - where is solution? I do not know when the battery is going to unplug..