almost every application requires to save and recall some custom settings in EEPROM between power off. Attached is simple component which accomplishes just that. All you need to do is declare some structure to hold application settings and to initialize component. Demo project attached. Tested with PSoc5LP (Creator 3.0).
Several options available: CRC8 check upon recall, variable CRC seed value (can change for different apps), variable EEPROM start address (can use multiple instances of the component to save several buffers), Temperature check for operation in adverse conditions.
The easy way to get the EE back into RAM is just use a byte pointer to the
address of the first element in structure, anopther one for RAM, and in a for()
loop just read back into RAM structure until you have read the total number of
bytes contained in the structure. This method does not care what type of
elements in structure, just dupes byte for byte what was saved in EE.
Main feature of the component is CRC check. Without it I wouldn't trust application settings recalled from EE. This is particularly important as I re-use same PSoC development kit for various projects. With this component I can effortlessy save one project at e.g. address 0, CRC 0; another project at addr. 10, CRC 128; etc.- they all can coexist together, and unique CRC for each project will ensure not oly integrity but also uniqueness of data.
But other than that component simply saves/recalls a buffer thru pointer as you mentioned above, very simple implementation for self-education purpose mainly.
Odissey1, I am curious, have you done any testing about R/W reliability of EEPROM ?
Is it inferior to standard FLASH operation, to wit driving the need for CRC ?
It could be in the rush to market they have not completed characterization for the
EEPROM component. Or there is a process difference....Not sure without filing a
In the case of FLASH one can always wear level it and get EEPROM like performance.
This component is just what I am looking for, especially the CRC capability . How can I get it from the demo project into my project component library?
Thank you. Somewhere on the Cypress site there is all I need to know. The magic is finding it.
Odissey1, are you aware of any emulated EEprom utilities for psoc4. I would like to be able to dump portions (or all) of flash to an uart port to see flash contents as I develop in psoc4
For sending flash data to UART you do not need an EEprom, just define a byte pointer and send out the data. A byte-to-ASCII conversion might be needed. What exactly from flash do you want to see on the other UART side? When you are using an CY8CKit-049 there might be a more elegant solution.
I am using the Pioneer kit and had loaded an example EM-EEprom (eeprom emulation using flash). The example declared a simple 14 byte array that I assumed was used by the component to allocate space in the flash. I thought it would be good to be able to dump flash and see where my small string was stored and also see how easy it would be for someone to retrieve said data. Do you think there is a simpler way to dump the flash to a serial port? I haven't seen a memory map for the psoc4 yet (I'm using the cy8c4245)? It would be nice if there was a utility that should flash, etc
When compiling a project with Creator there are under the "Results"-tab in workspace explorer
.lst Listing files for each .c file
a .map file, the output from the link-step
and a .rpt report file showing usage of the PSoC internal hardware usage and timing analyzes.
The result .hex-file contains all flash data and is human readable.
A utility that "flashes"? Writing to flash yourself?? It exists, have a look into the "System Reference Guide" and a memory map is explained in the device's Technical Reference Manual
I have researched the TRM manual, but could not find the System Reference Guide that you described as already having a flash dumping utility. Can you advise where the System Reference Guide is located?
Also, can you show me how a simple loop would look to dump flash to a serial port?
Are you concerned about security of FLASH ?
Dumping FLASH to UART is pretty simple, either a loop with byte write
or use PrintString API if strings are involved.
Yes, I am interested in security of the intellectual property of the code. I have read the SRM section on security and would like to do further work on encoding data that would be saved into emulated eeprom. In order to do that kind of work I would like to be able to dump flash contents first. Could you give an example of a tight loop to dump flash using the PringString API. I see memory map describes range as 0 - 00007FFF
char * Pointer;
for(Pointer = (char *)0;Pointer < (char *) 0x7fff;Pointer++) UART__UartPutChar(*Pointer);
And the "System Reference Guide" you will find using Creator's Help-menu.
Thank you. I have expanded the EM Eeprom Demo using your suggestion to make a legacy type hex screen dump. Very interesting that my code including the demo power cycle register starts at 0974. Do you know why it would be at that random address in flash? Could it be my app starts at a lower address and the emulated eeprom and strings are stored higher. It would be nice if you could nail down exactly where an important config string was stored.
I do get an error status code as expected when I do a "status = Em_EEPROM_Write(&eeprom_cnt,&eepromArray,1u);" after I write protect that block in flash security. So is there a way for me to protect my code but still allow my application to read and write to emulated eeprom? I would like a fool proof way of protecting my code and any dynamically stored data from being viewed.
See my example app and output below.
Oh, I wasn't able to find the utility that allows for viewing of flash outside of the application. That would be good to be able to test chip protection.
while (1u == 1u)
/* Forever loop */
// THIS IS NEW EEPROM (FLASH) DUMP CODE
while(Pointer < (char *) 0x7FFFD) //was formerly 7FFF, but 8000 is 32k
CyDelay(1500); //this to delay every 20 lines or so to see realtime
SW_Tx_UART_PutHexInt(Pointer); //Address we are pointing too for start of line ...xxxx
for(myx=0; myx<16; myx++)
SW_Tx_UART_PutChar(58); // colon
SW_Tx_UART_PutHexByte(*Pointer);//contents in hex
//now to the right display ascii representation or '.' if non ascii
Pointer=Pointer-16; //rewind pointer to look at start of line
for(myx=0; myx<16; myx++)
if((*Pointer > 48) && (*Pointer < 122))SW_Tx_UART_PutChar(*Pointer);
SW_Tx_UART_PutString("End of Forever");
Output to follow:
Em EEPROM demo
Former config byte is -->Powercycle# 4
EM EEPROM Write Success
EM Readback Success
0000 :00:10:00:20:9B:00:00:10:A5:03:00:00:A5:03:00:00 ................
0010 :A5:03:00:00:A5:03:00:00:A5:03:00:00:A5:03:00:00 ................
0020 :A5:03:00:00:A5:03:00:00:A5:03:00:00:A5:03:00:00 ................
0030 :A5:03:00:00:A5:03:00:00:A5:03:00:00:A5:03:00:00 ................
0990 :00:00:00:00:50:6F:77:65:72:63:79:63:6C:65:23:20 ....Powercycle..
09A0 :30:00:50:6F:77:65:72:63:79:63:6C:65:23:20:32:00 ..Powercycle..5.
09B0 :45:6D:20:45:45:50:52:4F:4D:20:64:65:6D:6F:00:42 Em.EEPROM.demo.B
09C0 :6F:6F:74:69:6E:67:20:69:6E:74:6F:20:50:72:6F:67 ooting.into.Prog
09D0 :72:61:6D:20:4D:6F:64:65:2E:2E:2E:00:42:6F:6F:74 ram.Mode....Boot
09E0 :69:6E:67:2E:2E:2E:00:46:6F:72:6D:65:72:20:63:6F ing....Former.co
09F0 :6E:66:69:67:20:62:79:74:65:20:69:73:20:2D:2D:3E nfig.byte.is...>
This is NOT a good example! Too much going on here. How about a simpler example that takes ONE BYTE and shows how to save it to EEPROM and then how to read it back. Not everyone knows about UARTs, ADCs, etc., nor do they want to connect an LCD, sensor, or something else. The simpler the better. Thanks for sharing your project or pointing others to it, but we have a lot of newcomers who can get lost in complicated "examples."
This is not a teaching example. This is custom community component for use in real applications, which allows to save/restore all application settings (strings, integers, floats etc. +CRC) in a single call. It was designed for experienced users.
The component is almost 5-years old.
Good wake-up call, anyways, just in time!
Provided below is updated version of the custom component (myEEPROM v0.1) for interfacing with PSoC5 EEPROM.
The previous version (0.0) is slightly dusted-off and re-compiled using Creator 4.0 SP1 using CY8CKIT-059. Simplified demo is provided.
Component provides simple solution for writing and reading multiple data into PSoC5 EEPROM. It is useful for storage of the setup parameters between PSoC5 power-offs. Using this component multiple parameters of varios types (int8,16,32, float, double, string) can be saved/restored using a single call.
variable seed value for CRC operation,
variable EEPROM address
multiple instances to save several buffers
Temperature check for operation in adverse conditions
The component was tested using CY8KIT-059 PSoC5 prototyping kit. Demo project is provided.
Attached archive contains component library and demo project for PSoC5. Please read installation instructions in the readme.txt.
The component provided as-is, no liabilities. It is free to use and modify.