Hello dango.1 (Community Member)
You can refer to the STM32Cube_FW_L0 example below:
\STM32Cube\Repository\STM32Cube_FW_L0_V1.12.1\Projects\NUCLEO-L031K6\Examples\FLASH\FLASH_EraseProgram.
It shows how to use Flash HAL function to first unlock the flash then erase a page and finally write a word.
However, you also have to check the flash erase/programming maximum cycle if it fits to your application ?
However, for user data, the STM32L041 (categorie 2) device embed 1 Kbyte of data EEPROM that is very suitable to store user data.
You can find the relative function to manage EEPROM located in stm32l0xx_hal_flash_ex.h / .c
Best regards,
Romain
In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.