Announcements
Community Announcement : Welcome to the NEW Cypress Developer Community.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

ToVa_285016
Contributor

 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
Expert II

use

   

const struct { ...

   

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

   

 

   

Bob

0 Likes
ETRO_SSN583
Esteemed Contributor

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
Expert II

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