simple test EEPROM emulation (STM algorithm described in the application notes: AN4061, AN3969, AN2594, AN3390, AN4056) for STM32F091

Dependencies:   mbed

Description in AN4061 from STM.

Changed (compared with the original code AN4061):

  • possibility of a larger size of emulated EEPROM (using multiple Flash pages)
  • dummy variables prevent overwrite code in Flash by algorithm of EEPROM emulation




Macro PAGE_NB_PVP (in eeprom.h) defines the size of the virtual page.
Eg. For F091 where Flash page are 2kB value 4 gives 8kB.

Size 8kB virtual page gives you the ability to use max. approx. 2k of 16-bit variables.

Files at this revision

API Documentation at this revision

Comitter:
mega64
Date:
Fri Jul 29 21:18:28 2016 +0000
Parent:
1:e91328f723ab
Child:
3:a51a1737b55d
Commit message:
Protect flash area of EEPROM simulation in case a larger code

Changed in this revision

eeprom/eeprom.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/eeprom/eeprom.cpp	Sun May 29 02:04:21 2016 +0000
+++ b/eeprom/eeprom.cpp	Fri Jul 29 21:18:28 2016 +0000
@@ -47,6 +47,10 @@
 /* Private macro -------------------------------------------------------------*/
 /* Private variables ---------------------------------------------------------*/
 
+/* Dummy variable to protect eeprom pages if code size is bigger than 32kb (F401) */
+const uint8_t Eeprom_area[2 * PAGE_SIZE] __attribute__((at(EEPROM_START_ADDRESS),used))={ [0 ... (2 * PAGE_SIZE-1)] = 0xFF };
+
+
 /* Global variable used to store variable value in read sequence */
 uint16_t DataVar = 0;
 
--- a/main.cpp	Sun May 29 02:04:21 2016 +0000
+++ b/main.cpp	Fri Jul 29 21:18:28 2016 +0000
@@ -1,23 +1,17 @@
-/**
- ******************************************************************************
- * @file    main.cpp
- * @author  ANG Group (Nelson Santos; Irina Baptista; Pierluigi Urru)
- * @version V0.0.3
- * @brief   Simple Example application for using the X_NUCLEO_IKS01A1
- *          MEMS Inertial & Environmental Sensor Nucleo expansion board.
- ******************************************************************************
-*/
 
 #include "mbed.h"
 #include "eeprom.h"
 #include <ctype.h>
 
+
+
 uint16_t n = 0;
 /* Virtual address defined by the user: 0xFFFF value is prohibited */
-uint16_t VirtAddVarTab[] = {0x5555, 0x6666, 0x7777};
+uint16_t VirtAddVarTab[NB_OF_VAR] = {0x5555, 0x6666, 0x7777};
 uint16_t VarDataTab[] = {0, 0, 0};
 
 
+
 int main()
 {
 
@@ -86,7 +80,7 @@
         }
 ////////////////////////////////////////////////////////////////////////////////////
         else if (strcmp("T2", command)==0) {
-            // multiple write test. After test var1 = 1001
+            // multiple write test. After test var2 = 1001
             printf("\nok");
             for (n=0;n<1002;n++)
             {
@@ -95,7 +89,7 @@
         }
 ////////////////////////////////////////////////////////////////////////////////////
         else if (strcmp("T3", command)==0) {
-            // multiple write test. After test var1 = 1002
+            // multiple write test. After test var3 = 1002
             printf("\nok");
             for (n=0;n<1003;n++)
             {
--- a/mbed.bld	Sun May 29 02:04:21 2016 +0000
+++ b/mbed.bld	Fri Jul 29 21:18:28 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/7c328cabac7e
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/f9eeca106725
\ No newline at end of file