STM32 EEPROM Blue Pill
STM32 EEPROM Emulation - EEPROM is an extension of Electrically Erasable Programmable Read-Only Memory, a memory chip that can store data even if power or resources are disconnected.
Generally every microcontroller already has an Internal EEPROM, this makes the circuit simpler without having to add an external chip.
Unlike Arduino which has an internal non-volatile storage chip, some Blue Pill devices do not have it. For this reason, if we want to save data to Blue Pill, we need a method that can allocate program flash memory as EEPROM.
In the official language of the ST datasheet, this memory allocation is called STM32 EEPROM Emulation. I have never used this on Arduino, so from that I shared a little program in this Article.
A. STM32 EEPROM Emulation
This emulation is done by considering the limitation of Flash memory and some requirements. This approach requires at least two pages of flash memory of the same size allocated for non-volatile data. For a more complete explanation of this EEPROM Emulation, please read the official ST document.
|STM32 EEPROM Arduino|
Officially, to program this chip using software from the ST itself named STM32CubeIDE. But because I'm not familiar with it, I just use Arduino IDE because there are already many libraries available.
Well, because the Arduino IDE is basically an IDE for programming AVR, someone developed a library board for this chip to be used in the Arduino IDE. This is very useful.
B. Library for STM32 Emulation Arduino
The library board to support this chip to be programmed using the Arduino IDE has several options. However, the library board that I use on this project is STM32 Arduino Core.
This Arduino Core STM32 tries to emulate this non-volatile storage access way as in Arduino. STM32 Arduino Core provides this library which I managed to try.
If we use arduino, to write data just use "EEPROM.write (address, data)" and read with "EEPROM.read (address)".
Whereas what I use to write is "EEPROMwrite (address, data)" and reads with "EEPROMread (address, data_data)".
The STM32 program is to use ST-LINK V2 Clone (China) and for serial monitor communication I connect FTDI on pins A9 and A10.
Below is the program code that I have tested and succeeded. Please upload the following STM32 EEPROM code to your STM32 and open Serial Monitor to see the stored data and the results of reading the data.
C. Schematic For Testing
To program this Blue Pill, I use ST Link V2. For serial communication, using FTDI, please follow the following table
D. Progam Code STM32 EEPROM Emulation
|Result from STM32 EEPROM|
May be useful.