Skip to main content
migmel
Associate III
April 21, 2022
Solved

How to read/write to STM32L071B flash memory using LL/Registers ?

  • April 21, 2022
  • 3 replies
  • 4025 views

Hello, I am trying to find LL functions parallel to those in HAL library that support Flash programming and it looks like there is not support in LL for r/w flash. As HAL library is not an option for me, I am wondering if it is possible <writing directly to registers> achieve this goal, not so easy for me though.

Any help/suggestion in how to go about it would be greatly appreciated

Best answer by TDK

The RM would be the best reference to use for writing to the FLASH. It is more complicated than RAM, but should be quite manageable. There are even code examples for how to do this in the RM. See "A.3.9 Program a single word to Flash program memory code example". Note that flash needs unlocked first.

https://www.st.com/resource/en/reference_manual/rm0377-ultralowpower-stm32l0x1-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

Reading flash memory should be a trivial task. There are no special considerations here, read it the same as yo would RAM.

3 replies

TDK
TDKBest answer
Super User
April 21, 2022

The RM would be the best reference to use for writing to the FLASH. It is more complicated than RAM, but should be quite manageable. There are even code examples for how to do this in the RM. See "A.3.9 Program a single word to Flash program memory code example". Note that flash needs unlocked first.

https://www.st.com/resource/en/reference_manual/rm0377-ultralowpower-stm32l0x1-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

Reading flash memory should be a trivial task. There are no special considerations here, read it the same as yo would RAM.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate III
January 5, 2024

Still, LL should be provided.

migmel
migmelAuthor
Associate III
April 23, 2022

Thank you @TDK

waclawek.jan
Super User
January 5, 2024

Well, Cube is open source, so you can "translate" the Cube/HAL based examples into register accesses, and then "reverse translate" those to the Cube/LL macros/functions.

JW