cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L0 eeprom writting issue after a page erase

tingting
Associate II
Posted on October 09, 2015 at 13:14

Hi,

I cannot  write any data into the eeprom after a Erase_page.

HAL_FLASH_Program(..) and FLASH_Erase_Page(...) work fine independently. But if HAL_FLASH_Program(...) is called just after FLASH_Erase_Page(), HAL_FLASH_Program is not working. The data written are always 0x00.

Despite a 10 ms delay after the FLASH_Erase_Page, it is not working.

Thanks.
4 REPLIES 4
e1369008
Associate II
Posted on October 09, 2015 at 13:31

You shouldn't just wait for x milliseconds, you should wait until the busy flag is cleared from the FLASH_SR register, then check for the error flags, if everything is OK only then process to the next operation with the EEPROM.

What library are you using? HAL, Snippets?
tingting
Associate II
Posted on October 09, 2015 at 13:47

I am using HAL library.  The HAL_FLASH_Program implements an instruction to wait for last operation to be completed.

e1369008
Associate II
Posted on October 09, 2015 at 13:51

Then why are you using HAL_FLASH_Program(..) and FLASH_Erase_Page(..) function to porgram the EEPROM? Shouldn't you use the EEPROM functions. I'm not using HAL but here are the functions I could find related to the EEPROM:

HAL_FLASHEx_DATAEEPROM_Unlock

HAL_FLASHEx_DATAEEPROM_Lock

HAL_FLASHEx_DATAEEPROM_Erase

HAL_FLASHEx_DATAEEPROM_Program

..and some others..

tingting
Associate II
Posted on October 09, 2015 at 14:04

you're right!

Indeed ,these functions work fine!

Thank you very much.