2 Replies Latest reply on Apr 8, 2019 12:21 AM by GeonaP_26

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

    ivkac_4155501

      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.

        • 1. Re: Emulated EEPROM what does ..._Write() function exactly do?
          MoTa_728816

          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

          • 2. Re: Emulated EEPROM what does ..._Write() function exactly do?
            GeonaP_26

            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");
                }