0

I am currently working on Nucleo f207zg. I want to write its variables into its permanent memory (EEPROM). How can I achieve it?

I am unable to find read or write functions for the same.

Vandini
  • 11
  • 1
  • It doesn't look like this part has EEPROM. It has 4 KB of SRAM that can be battery-backed and used as non-volatile memory. Please take time to do research on the part you're using. – Thomas Jager Jun 05 '19 at 13:06
  • how can I access SRAM to store my data even after power off? – Vandini Jun 07 '19 at 05:46

1 Answers1

2

STM32F2 controllers don't have internal EEPROM memory.

They have FLASH instead, with only 10000 guaranteed erase cycles, and comparatively large erase block size at 128 kBytes. AFAIK it does not support read-while-write operations, so the whole system comes to a stillstand while contents are updated.

It'd be still useful for storing stuff that does not change too often, e.g. user preferences or calibration values.

Unlike some other controller series, flash write functionality is described in a separate document, the STM32F207 Flash programming manual. There are no "read functions", since its contents can be read as any other internal memory cell.

  • I am interested in changing the IP of the board.IP of the board changes(I am able to ping it) but once I reset it, it automatically takes the default IP which I had set in STM32 CubeMX. How can I save the changed IP in permanent memory. – Vandini Jun 06 '19 at 04:58
  • An IP Address can be stored in 4 bytes. When the flash is erased, all bytes are set to 255. As `255.255.255.255` is not a valid IP address, you can simply look for the first unused slot in the flash block, and write the address there. At startup, look for the last valid record in the flash. When the flash sector is full, erase it and start over. – followed Monica to Codidact Jun 06 '19 at 08:02
  • can we do it directly using header files stm32f2xx_hal_flash.h and stm32f2xx_hal_flash.h? I am programming it on keil version 5. – Vandini Jun 06 '19 at 09:37
  • There should be a couple of example programs shipped with the HAL library that use this interface. If you can't find them, download the whole [STM32CubeF2 package](https://www.st.com/en/embedded-software/stm32cubef2.html). – followed Monica to Codidact Jun 06 '19 at 10:28
  • I just matched the address of the variable IP_ADDRESS (where it is stored in memory). I got to know that it is stored at address 0x2000 0018 which is the address in sram. i want that if I change the value of this variable then on resetting it should hold the changed value. – Vandini Jun 07 '19 at 05:48
  • **Don't change the RAM contents directly.** That address might change whenever you introduce a new variable in the program, and you'd end up changing some unrelated variable to the stored IP address. To find out by name which variable is stored at the address, [generate a linker map file](https://stackoverflow.com/questions/51190256/how-to-enable-the-linker-map-file-generation-in-keil) and find the address in it. Now you can track it down in the source code, and find out how it is initialized. – followed Monica to Codidact Jun 07 '19 at 06:17