Go Down

Topic: Arduiuno internal EEPROM, how long does reading take? (Read 202 times) previous topic - next topic

Infraviolet

I found that writing takes 3.3ms per byte, but couldn't find figures for reading. I've got a situation where I read the internal EEPROM as soon as my arduino powers on, do my stuff in code using variables to hold the values which came from the EEPROM, and write those variable values back into the EEPROM just before I turn off (turning off is a planned event not a sudden cutting of power, it's done via a system where a user presses a button and the actual power off event comes a few seconds later when the arduino, upon seeing such a button press, changes a GPIO output so as to cut off power to a relay which powers the whole system). I only use three bytes (I've been using bytes 0, 1 and 2 of the EEPROM each time, as I'm only reading on powerup and writing on powerdown I don't expect life cycle problems. I guess the life would be longer if I cycled through all the EEPROM bytes but then I'd have no clue which byte addresses to read from when I powered up), and an extra 9.9ms during powerdown is not a problem for me, but knowing how long it takes to do the reading during powerup is very important. Thanks.

I'm using an ATMEGA328P based uno.

P.S. I'm nearly certain of this but, just to check, the EEPROM can be assumed to preserve data pretty much indefinitely (months atleast) when the chip is completely unpowered? There's no need for any kind of thing like a "BIOS battery" or little capacitor built into the atmega for which the EEPROM only keeps it's memory as long as this stays charged?

P.P.S. For various reasons of fast starting up I have to use my arduino without a bootloader and with custom fuses set. I haven't changed the brownout fuse bit, only the one which afefcts startup time, I startup in 16K clcok cycles plus 0ms ratehr than wait an extra 65ms to start. Is it ok to read from EEPROM instantly after starting or should I delay for several micro or milliseconds after starting up before I execute my initial read. When powering down it's less of a concern, I can do the EEPROM write inbetween a pair of multi-second delays, the relay not being switched off until the second delay ends.

GolamMostafa

#1
May 16, 2019, 12:46 am Last Edit: May 16, 2019, 12:47 am by GolamMostafa
1.  Write sequence in an EEPROM location (1-byte):
(1)  Select the memory location (0x0010) via address register/user variable.
(2)  Place data (0x23) via data register/user variable.
(3)  Assert 'write strobe' signal via control register.
(4)  Wait for about 5 ms to get the data byte fused inside the target location.

All the above tasks are done by the following command:
Code: [Select]
EEPROM.write(0x0010, 0x23);

The write time is approx. 5 ms/byte (forget the tiny period spent for each sub task).

2.  Read sequence from an EEPROM location (1-byte):
(1)  Select the memory location (0x0010) via address register/user variable.
(2)  Assert 'read strobe' signal via control register.
(3)  Data is available to the user via data register/user variable

All the above tasks are done by the following command:
Code: [Select]
byte x = EEPROM.read(0x0010);

The read time is approx. 0 ms/byte (forget the tiny period spent for each sub task).


Smajdalf

According to the datasheet reading EEPROM byte takes 4 clock cycles. Unless you do something really time critical where you are counting every cycle the time is negligible (for comparison reading from SRAM takes 2 cycles).

EDIT to your other questions:
EEPROM is non-volatile, it does not need a back up battery and data should survive for years.
You can read the EEPROM ASAP, no need for waiting.
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

Infraviolet

Thanks for those answers, glad to have everything clear now.

Go Up