Emulated EEPROM what does ..._Write() function exactly do?

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

cross mob
ivkac_4155501
Level 1
Level 1

Dear community,

I have a question about how exactly the emulated EEPROM function Write() works:

I have a constant array

const uint8 store[SIZEOF_EEPROM_ROW] = {};

Then I have an array

uint8 zustand[SIZEOF_EEPROM_ROW] = {};

zustand[0] = 3;

later in the code I use the Write function.

writeStatus = Em_Eeprom_Write(zustand,store,1);

I thought when the write function is done, the first entry of store array must be 3, but it is apperently not because when I test it:

    if(store[0] == 3)

    {

        n++;

    }

it just skips it.

0 Likes
1 Solution
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

I wonder whether the writeStatus is successful. Hence, please change it to, writeStatus = Em_EEPROM_Write(zustand[0], store, 1); the writeStatus will be successful. It writes one byte of data from source array (namely store in this case) to third logical position of Em_EEPROM data storage. If you read back the Em_EEPROM data storage, the third byte will be store[0]. Since store array is empty, please modify the firmware to following. For better understanding, please refer to Em_EEPROM datasheet.

    const uint8 store[SIZEOF_EEPROM_ROW] =  {11,22,33,44};

    uint8 zustand[SIZEOF_EEPROM_ROW] = {};

    zustand[0] = 3;

    UART_PutString("EmEEPROM demo \n\r");

    /*Initalize EEPROM with the start address of the memory location*/

    eepromReturnValue = Em_EEPROM_Init((uint32_t)Em_EEPROM_em_EepromStorage);

   

    /*Write contents to EEPROM */

    eepromReturnValue = Em_EEPROM_Write(zustand[0], store, 1);

    /*Read contents of EEPROM after write*/

    eepromReturnValue = Em_EEPROM_Read(0, eepromArray, 10);

    if(eepromArray[3]==11)

    {

        UART_PutString("The third position of Em_EEPROM storage is 11 \n\r");

    }

View solution in original post

0 Likes
2 Replies
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

In the shortest words, you can read

Cy_Em_EEPROM_Write() function in cy_em_eeprom.c

if you need to know exactly what it does.

But for a general grasp, I've just tried by myself using CY8CKIT-059.

As GeonaM_26-san wrote in Using EEProm

EEPROM and Em_EEPROM are quite different stuff.

I needed to read the datasheet and modify the linker script to make it work.

The result terminal output was something like

000-TeraTerm-log.JPG

Here Store is the actual Em_EEPROM address (in the Flash ROM),

and it seems that the Write function is taking care of wearing level and number of data,

so the first 12 bytes are seemed to be used for the house keeping and actual data was

written from the 13th byte.

But from application stand point, data written and data read were same.

moto

0 Likes
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

I wonder whether the writeStatus is successful. Hence, please change it to, writeStatus = Em_EEPROM_Write(zustand[0], store, 1); the writeStatus will be successful. It writes one byte of data from source array (namely store in this case) to third logical position of Em_EEPROM data storage. If you read back the Em_EEPROM data storage, the third byte will be store[0]. Since store array is empty, please modify the firmware to following. For better understanding, please refer to Em_EEPROM datasheet.

    const uint8 store[SIZEOF_EEPROM_ROW] =  {11,22,33,44};

    uint8 zustand[SIZEOF_EEPROM_ROW] = {};

    zustand[0] = 3;

    UART_PutString("EmEEPROM demo \n\r");

    /*Initalize EEPROM with the start address of the memory location*/

    eepromReturnValue = Em_EEPROM_Init((uint32_t)Em_EEPROM_em_EepromStorage);

   

    /*Write contents to EEPROM */

    eepromReturnValue = Em_EEPROM_Write(zustand[0], store, 1);

    /*Read contents of EEPROM after write*/

    eepromReturnValue = Em_EEPROM_Read(0, eepromArray, 10);

    if(eepromArray[3]==11)

    {

        UART_PutString("The third position of Em_EEPROM storage is 11 \n\r");

    }

0 Likes