Skip to main content
YBend.1
Associate III
Jan 31, 2023 6:16 AM UTC
Solved

Facing problems with saving data to flash memory on stm32g030c8t6.

I tried implementing a driver by following the Flash example present of the GitHub page and a blog I found online:

How to Program Flash memory in STM32 » ControllersTech

The driver code according to this blog is: STM32/FlASH_PAGE_F1.c at master · controllerstech/STM32 (github.com)

I tried to implement it for my application: Eeprom-Emulation-driver-STM32/FlASH_PAGE_F1.c at main · Yadnik1/Eeprom-Emulation-driver-STM32 (github.com)

However, no data is being stored in the flash memory. I am making a mistake that I am not able to identify it, can someone please guide me with it.

Thank you very much!!

This topic has been closed for replies.
gbm
gbmBest answer
Super User
Jan 31, 2023 7:51 AM UTC

Read the section on Flash in the Reference Manual for G0 chips. Unlike in F1, in G0 Flash is written in 64-bit units - two 32-bit words must be written one after another in a single programming operation.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

5 replies

gbm
gbmBest answer
Super User
Jan 31, 2023 7:51 AM UTC

Read the section on Flash in the Reference Manual for G0 chips. Unlike in F1, in G0 Flash is written in 64-bit units - two 32-bit words must be written one after another in a single programming operation.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
YBend.1
YBend.1Author
Associate III
Jan 31, 2023 8:20 AM UTC

Thanks @gbm​,

Can you please tell me, how to convert the logic into code.

From my understanding, the change will happen in this part:

while (sofar<numberofwords)
	 {
	 if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, Address, Data[sofar]) == HAL_OK)
	 {
	 	 Address += 8; // use StartPageAddress += 2 for half word and 8 for double word
	 	 sofar++;
	 }

Thank you very much !!

gbm
Super User
Jan 31, 2023 10:20 AM UTC

I don't use HAL and I have no reason to learn/understand it. I am afraid I cannot help you with any HAL-based stuff.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
YBend.1
YBend.1Author
Associate III
Jan 31, 2023 10:22 AM UTC

Okay @gbm​. Thanks for your help.

YBend.1
YBend.1Author
Associate III
Feb 1, 2023 6:13 AM UTC

Can someone else please help me with this, or should I open up a new thread for this?

Thanks.