Should we check EEPROM is ready before reading/writing to it

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using Atmega328 EEPROM. Should I use eeprom_is_ready() before reading and writing to EEPROM?

I notice that the EEPROM.write() and EEPROM.read() in arduino library does not use eeprom_is_ready(). Is this a bad practice?

The article below recommends that we always check the EEPROM before read/writing to it. What is the consequence of not doing so? Will it cause EEPROM value to be mis-written?

http://michael.bouvy.net/blog/en...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which C compiler are you using? Your mention of Arduino makes me suspect it is avr-gcc. In which case just use the functions in:

http://www.nongnu.org/avr-libc/u...

use the eeprom_update*() functions to write (they are better than eeprom_write*()) and use eeprom_read*() to read. You don't need to worry about waiting for things to be ready as that's already done where necessary inside those high level APIs.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The OP said:

Quote:
I notice that the EEPROM.write() and EEPROM.read() in arduino library does not use eeprom_is_ready().

True, but they call a function that does check and waits for the eeprom ready before performing the read/write.
Many details are hidden from view in the Arduino environment. The article you refer to is calling toolchain lib's directly, so research the doc on the lib calls for details on how to use them correctly.
Yes, not waiting for previous operations to complete before starting new ones will cause problems.

JC