cancel
Showing results for 
Search instead for 
Did you mean: 

Maintain Codes After Power Off

AE104
Senior

Hello,

I developed a custom-designed system with an STM32F767 microprocessor and controlled its parameters with a user interface through a Bluetooth module. When I power off then power on the system, I couldn't communicate with the circuit board. Is there a way to store codes without affecting power off?

Thank you,

15 REPLIES 15

Use battery-backup RAM, an external EEPROM, or portion of the internal FLASH.

JW

AE104
Senior

How can use internal FLASH?

Read the FLASH chapter in RM.

JW

AE104
Senior

I have checked the reference manual, https://www.st.com/resource/en/reference_manual/dm00224583-stm32f76xxx-and-stm32f77xxx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf

Then I see the flash memory bank and section address and commanding flash memory. But I don't know how exactly to place my codes in flash memory?

TDK
Guru

Flash is non-volatile, which means it will keep its value after reset. However, you must erase an entire page of flash before writing to it instead of accessing bytes as in RAM. Programs typically store user data by reserving an entire page of flash. Using a page of flash in this way is sometimes called EEPROM emulation.

Here's an example:

https://github.com/STMicroelectronics/STM32CubeF7/tree/c7c5ec99c7482ea8bcdbf0a869c930af4547088f/Projects/STM32F769I_EVAL/Applications/EEPROM/EEPROM_Emulation

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

Put the data in a structure, erase a sector you've chosen or set aside for this purpose, erase then write the block of data into it.

STM32Cube_FW_F7_V1.16.0\Projects\STM32F767ZI-Nucleo\Examples\FLASH\FLASH_EraseProgram

Probably want to floor-plan some of the smaller sectors/blocks so it uses less resources, and is quicker.

If multiple instances of the data structure will fit you can journal them across the available space, with perhaps checksums and sequence numbers, so you can recover the latest data when you restart.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AE104
Senior

Thank you for your comments!

I verified that the codes were stored in the flash memory bank 2 with STLink utility (attached figure). To diagnose the problem, I placed led blinking comments after receiving data commands from the UART and after sending data commands with the UART. When I powered off and then power on the circuit, it received the data but it didn't send it back. How can I solve this issue?

Piranha
Chief II

My crystal ball indicates that the author did mislead all the previous experienced users... Probably the author saw that the device is not working as expected and assumed that it's because the code is erased/not stored.

Therefore the solution is to debug and fix the code. And there are a zillion UART/USART related topics. One of the best is this:

https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

AE104
Senior

@Piranha​ Thank you for reporting the crystal ball view.

On my system, I used the UART in polling mode, so does it may reason to fail the system when transmitting data? I checked the link that you have linked, so based on the pros and cons of the modes, does the DMA mode operation solve the problem?