- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to use the emulated eprom (version 1.10) in PSoC 4 to save some data. My flash is almost full, I have about 4k bytes left.
This code came from PSoC 5, where the eeprom exists, and I may wish to take it back again, so some things are left in place.
The problem is the write call happens, and does not complain. However, the data is never written to the flash variable "settings." It always retains its old value. If I don't initialize it, it remains a value of "0" after the write. Data sheet recommends initializing.
Has anyone gotten this to work for the PSoC 4? It works well in EEPROM for PSoC 5.
wade
Code:
typedef struct eeprom_data_struct {
union {
float f;
uint8 b[sizeof(float)];
} offset;
union {
float f;
uint8 b[sizeof(float)];
} slope;
} EEPROM_DATA;
EEPROM_DATA ramSettings;
const static EEPROM_DATA settings = {{1.094},{3.072}};
//-----------------------------------------------------------
//-----------------------------------------------------------
void read_eeprom() {
EEPROM_Start();
offset = settings.offset.f;
slope = settings.slope.f;
ramSettings = settings; // copy into ram
EEPROM_Stop();// power down the EEPROM
}
//-----------------------------------------------------------
//-----------------------------------------------------------
void saveSettings() {
EEPROM_Start();
ramSettings.slope.f = slope;
ramSettings.offset.f= offset;
EEPROM_Write((const uint8*)&ramSettings,(const uint8*)&settings,sizeof(ramSettings)); // write first 16 bytes in one fell swoop
EEPROM_Stop(); // power down the EEPROM
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is an example project here that may be of help -
http://www.cypress.com/?rID=105775
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
' Thanks, I'll look into it.
At first glance, the code is pretty much the same pattern, unless making local variables does something special for the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also in Creator SP2 just released there is this update/fix -
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just installed SP2 today and tested on it. Even when running full speed without debugging, it fails.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did not have problems with the em_eeprom component yet. Will you mind to post your complete project (or a reduced example) that shows the error? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file. So we all here can look at all of your settings.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We had that issue before, it is a compiler flaw, your eeprom is written correctly, but the assing of the eeprom-data to your ram data fails. The compiler "knows" that your variable "settings" is a constant and has kept the values in "mind". When you now issue a
ramSettings = settings; // copy into ram
the compiler takes the values and fills ramSettings with those.
Use a memcpy() to shuffle the informations from eeprom to ram as in my attached project.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks,
I had the same problem,
the memcpy works for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks! I'll give that a try. It will take a day or two, other things are commanding attention at the moment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
this is a question for Bob Marlowe about his nice example PrototypeKit4.cywrk.Archive01.zip
Why do you use the instruction memset between these to Ram2EEProm and EEProm2Ram lines?
Ram2EEProm();
memset(&RamData,0,sizeof(struct EEEPromdata));
EEProm2Ram();
Thank you for your answer.
Best regards
Denis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum, Denis!
This was done just to verify when using the debugger that EEProm2Ram() filled the sram with new data.
Bob