How to retain a 32bit real value on FLASH Memory in STM32L041x6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-20 1:55 AM
Hi!
I am trying to store a real value in the flash memory of my STM32 but i am struggling to write it. Has anyone already done this in the same STM32L041x6 processor?
If so , how can i do it? also, is it possible to read it back?
Thanks in advance!!
Solved! Go to Solution.
- Labels:
-
Flash
-
STM32L0 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-20 7:40 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-20 1:59 AM
Imagine it is just 4-bytes of data, and use pointers, casting or union/struct​
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-20 2:46 AM
Ideally create a flash data sector in the linker config file so the address is fixed while your code grows. Use pointers as Clive mentionned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-20 2:59 AM
Thanks for the help! , do you know where could i find an example? I am really lost at this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-20 7:40 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-12-20 8:00 AM
Hi!
Thanks for the help!
My application is related to a brushless motor control ,i control its current and i wanted to implement a mode so i can change the intensity depending on the use but that if i turn off and on the microproccesor, that value is retained.
I will be trying the eeprom cause even though this mode will not be used many times,i don´t wanna waste the flash cycles.
