Skip to main content
migmel
Associate III
Apr 21, 2022 9:07 AM UTC
Solved

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

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

This topic has been closed for replies.
TDK
TDKBest answer
Apr 21, 2022 1:27 PM UTC

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""."

4 replies

TDK
TDKBest answer
Apr 21, 2022 1:27 PM UTC

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
Jan 5, 2024 12:30 PM UTC

Still, LL should be provided.

migmel
migmelAuthor
Associate III
Apr 23, 2022 2:53 AM UTC

Thank you @TDK

waclawek.jan
Super User
Jan 5, 2024 12:51 PM UTC

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