Skip to main content
gilramon
Associate II
November 10, 2021
Question

Writing to internal flash on STM32G0 series. Hello I try to write to the flash but I can't find good examples about it,

  • November 10, 2021
  • 4 replies
  • 6281 views

Please if you can give me a good link that show how can I use the HAL layer to write and read from the flash.

This topic has been closed for replies.

4 replies

TDK
November 10, 2021

Reading from flash is the same as reading from RAM. It's memory mapped, so just read it.

For writing, here is one example:

https://github.com/STMicroelectronics/STM32CubeG0/blob/c6c0046d9278a7107261c6bf38327345df4c3efd/Projects/STM32G0C1E-EV/Examples/FLASH/FLASH_EraseProgram/Src/main.c

"If you feel a post has answered your question, please click ""Accept as Solution""."
gilramon
gilramonAuthor
Associate II
November 10, 2021

#define FLASH_USER_START_ADDR ADDR_FLASH_PAGE_16 /* Start @ of user Flash area */

#define FLASH_USER_END_ADDR (ADDR_FLASH_PAGE_127 + FLASH_PAGE_SIZE - 1) /* End @ of user Flash area */

I 'm using STM32G070CB, I'm using CubeMX and keil for IDE.

Somewhat the parameter of ADDR_FLASH_PAGE_16 doesn't exist.

I try to configure how many pages I have in my MCU.

SoonuVerma
Associate
September 15, 2022

Hi @gilramon​ and @TDK​ , any update on this thread, Me itselt trying reading writing Flash in STM32G071Rb, unable to write anything, for me target it not responding, retrying error is there, there's no physical issue with the Nucleo-G071RB board and cable, working fine in other cases.

is it something with or clock or anything, earlier I was using TIM6 then Systick issues remains the same, HIS 64K is in use.

or if you have, can you share sample code ?  

TDK
September 27, 2022

I provided sample code in my first reply. Provide more details if you want a more informed answer. I am not psychic.

"If you feel a post has answered your question, please click ""Accept as Solution""."