Set EM_EEPROM Location

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ToVa_285016
Level 5
Level 5
100 replies posted 50 replies posted 50 questions asked

 Hi,

   

Are there any examples of how to set EM_EEPROM to a specific location, and then change that location after a certain amount of writes?

   

My EM_EEPROM is set up like this:

   

// EEPROM Array

   

static const uint8 CYCODE eepromArray[ARRAY_SIZE]= {0};

   

 

   

// Sets up data structure for EEPROM storage

   

struct eepromData

   

{

   

    uint8 mode;             // Running mode

   

    uint8 program;          // Program selected to run in program mode

   

    uint8 speed;              // speed of programs

   

    uint8 brightness;       // brightness of colors 0-10;

   

    uint8 spectrum;         // color based on spectrum location    

   

    uint8 white;            // white level for spectrum use

   

    uint8 channels;         // stores whether there are 3 or 4 channels (RGB vs RGBW)

   

} dataLocal;

   

 

   

And written like this:

   

// Writes EEPROM structure into memory

   

void WriteEEPROM()

   

{   

   

    cystatus status; 

   

    

   

    // Writes EEPROM data

   

    status = Em_EEPROM_Write((void *)(&dataLocal),(void *)(&eepromArray),ARRAY_SIZE);

   

}

   

Thank you,

   

Tom

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

use

   

const struct { ...

   

and initialize the members, then it will be put into flash.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Sounds like you want to do wear leveling.

   

 

   

To force absolute location - www.cypress.com/

   

 

   

    

   

          http://www.cypress.com/?rid=91945

   

 

   

In Help, System reference Guides, there is a section on FLASH APIs to work

   

with FLASH.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Hi, 

   

Anyone can you tell me how to Read the data which is written by Em_EEPROM_Write ? 

   

Is there any document telling about this?

   

Thanks & Regards,

   

Son

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Since you are using emEEPRom component to write, look at the second parameter:

   

eepromPtr: Pointer to the array or variable in flash representing the emulated EEPROM

   

so you just use *eepromPtr to de-reference. When using a variable in flash that was defined as

   

const uint16 MyEEPromVar = 0;

   

you better use memcpy() to retrieve the data: the compiler keeps the original value in mind and uses the initial const value of zero in this case.

   

 

   

Bob

0 Likes