3 Replies Latest reply on Oct 27, 2017 1:42 PM by michal.reznicek_1607246

    Why the RAM memory is used for store data in emulated EEPROM

    michal.reznicek_1607246

      Hello, I'm woring on a project which measure temperature and humidity. The measured data are stored in emulated EEPROM - FLASH (dataloging).

       

       

       

      I use two buffers:

      static const uint8_t Datalog_vlhkost[MAX_NUM_SAMPLE_DATALOG * 2];    // store MSB and LSB because data are 16bit

      static const uint8_t Datalog_teplota[MAX_NUM_SAMPLE_DATALOG * 2];    // store MSB and LSB because data are 16bit

       

      for example MAX_NUM_SAMPLE_DATALOG  = 500u

       

       

      when use : for write data to flash the very very area in RAM is occupied.

       

              status = Em_EEPROM_Write(....);

       

       

       

      Is it normal? why is the RAM memory alocated?

        • 1. Re: Why the RAM memory is used for store data in emulated EEPROM
          ntan

          I don't assume from your question what size of RAM is occupied by your program.  It is true the Emulated EEPROM requires some buffer on the RAM.

           

          The Emulated EEPROM uses internal Flash ROM to be accessed as an EEPROM.  You can write data at any location in any size on EEPROM, but not on Flash ROM.  The Flash ROM must be accessed with a data unit.  In PSoC 4, the data unit is called as ROW and the ROW size of CY8C4245AXI-483 is 128Bytes.

           

          Because Flash ROM can be write with a ROW size, the Emulated EEPROM executes following procedure when Em_EEPROM_Write() is called to write a data.

           

          1. Save a 128Bytes ROW data containing the destination address to a 128Bytes write buffer.
          2. Put the one byte of data to the write buffer.
          3. Write the write buffer to the 128Bytes ROW.

           

          In this sequence, a 128Bytes write buffer must be prepared.  In the Emulated EEPROM component, the write buffer is assigned to the Stack area as a local variable.  This is why the Emulated EEPROM occupies 128Bytes of stack area.  In addition, the procedure does not depend on the data size to be written.  Even if one byte is written, 128Bytes of buffer is required.

           

          Regards,

          Noriaki

          • 2. Re: Why the RAM memory is used for store data in emulated EEPROM
            user_1377889

            static const uint8_t Datalog_vlhkost[MAX_NUM_SAMPLE_DATALOG * 2];

            will NOT be allocated in flash, You will need to initialize your data with the definition as

            static const uint8_t Datalog_vlhkost[MAX_NUM_SAMPLE_DATALOG * 2] = {0,0};

             

            Bob

            1 of 1 people found this helpful
            • 3. Re: Why the RAM memory is used for store data in emulated EEPROM
              michal.reznicek_1607246

              Hello Bob and Noriaki

               

               

              thank you very much for your help.

               

              Michal