cancel
Showing results for 
Search instead for 
Did you mean: 

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

gilramon
Associate II

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.

4 REPLIES 4
TDK
Guru

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

#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 II

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 ?  

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