Skip to main content
ADębs.1
Senior
Jun 7, 2021 5:48 PM UTC
Solved

STM32F746, STM32CubeIDE

How to remember in STM32F746G-Disco uint32_t? Save after power off and recall when power is restored?

Andrzej

This topic has been closed for replies.
Maurizio1
Maurizio1Best answer
Associate II
Jun 11, 2021 4:05 PM UTC

This YouTube tutorial should help you: STM32 FLASH Programming || SECTOR TYPE || M4, M7

19 replies

Maurizio1
Associate II
Jun 7, 2021 6:32 PM UTC

Maybe you can use the SD card?

This tutorial is based on your board:

https://www.youtube.com/watch?v=I9KDN1o6924

Please use more more meaningful titles for your questions.

TDK
Jun 7, 2021 9:16 PM UTC

It takes some work if you want to store things on the chip itself. Dedicate a page of flash to storing user values. You must erase the entire page of flash to overwrite the values.

Otherwise use an external EEPROM/FRAM or SD card as Maurizio suggests.

"If you feel a post has answered your question, please click ""Accept as Solution""."
ADębs.1
ADębs.1Author
Senior
Jun 7, 2021 9:26 PM UTC

I need to save 4 bytes when power off.

Andrzej

Maurizio1
Associate II
Jun 7, 2021 9:42 PM UTC

This is an application note describing the process of so-called "EEPROM emulation".

AN3969

[Edited to link the AN about devices that are more similar to the one used by the OP]

It does not require a SD card to be present in your system (which already has a SD drive), but it's relatively more complex to be organized, as you have to know the layout of the embedded flash memory in order to not overwrite your own code.

If you can handle that, "EEPROM emulation" is probably better for a fixed, simple data as a 4-byte unsigned integer.

ADębs.1
ADębs.1Author
Senior
Jun 10, 2021 12:10 PM UTC

I want to write and read FLASH. Please send the sector addresses file STM32F7.

Andrzej

ADębs.1
ADębs.1Author
Senior
Jun 10, 2021 6:03 PM UTC

When I use "HAL_FLASH_Program (FLASH_TYPEPROGRAM_WORD, FLASH_SECTOR_4, total_time);" I need to "FLASH_Erase_Sector (FLASH_SECTOR_4, FLASH_VOLTAGE_RANGE_3);" ?

Andrzej

Maurizio1
Maurizio1Best answer
Associate II
Jun 11, 2021 4:05 PM UTC

This YouTube tutorial should help you: STM32 FLASH Programming || SECTOR TYPE || M4, M7

ADębs.1
ADębs.1Author
Senior
Jun 12, 2021 9:11 AM UTC

Thank you. I will write back.

Andrzej

TDK
Jun 10, 2021 6:08 PM UTC
"If you feel a post has answered your question, please click ""Accept as Solution""."
ADębs.1
ADębs.1Author
Senior
Jun 11, 2021 11:03 AM UTC

Need:

1.after turning on the power, read the saved value from FLASH (uint32_t)

2.Unlock FLASH 2. delete the FLASH sector

3.Set the power drop interrupt in StartTask02

4. write one byte in the interrupt (uint32_t)

5.Lock FLASH

Will it work?

Andrzej

Piranha
Principal III
Jun 12, 2021 4:17 PM UTC

Read the FLASH section in a reference manual and also the whole AN3969. Many current and future questions will be answered by that...