Your problem has to be solved in different steps
Putting a variable into flash instead of sram
static const uint16 MyVar = 0x20c0ffee; // This can be done with s struct to get more space
Initialization is required
Retrieving the data from flash:
Due to compiler optimization an assignment like
NewVar = MyVar;
Will assign 0x20c0ffee to Newvar, even when its value was re-programmed, so use memcpy() instead
Programming new values using the em_EEProm component
Result = Em_EEPROM_Write(&RamVar,&MyVar, sizeof(MyVar)); // Program the value of RamVar into flash, setting MyVar
The above needs some type-castings to uint8* to avoid warnings.
Hope that helps.
Note if doing a PSOC 4 BLE design, the eeprom component not
currently implemented. But the basic FLASH write techniques
can still be used.
I'm using the
Pioneer development board so I had to use the flash method. Works good.