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

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

cross mob
lock attach
Attachments are accessible only for community members.
MiRe_1607246
Level 2
Level 2

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?

0 Likes
1 Solution
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

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

View solution in original post

0 Likes
3 Replies
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

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

0 Likes

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

Hello Bob and Noriaki

thank you very much for your help.

Michal

0 Likes