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