Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of eeprom_update_byte instead of eeprom_write_byte #1459

Closed
wants to merge 1 commit into from
Closed

Use of eeprom_update_byte instead of eeprom_write_byte #1459

wants to merge 1 commit into from

Conversation

leomil72
Copy link

@leomil72 leomil72 commented Jun 9, 2013

Using eeprom_update_byte the code won't write on the EEPROM cell if it already contains the value that the user wants to write into it.

Using eeprom_update_byte the code won't write on the EEPROM cell if it already contains the value that the user wants to write into it.
@SpiRaiL
Copy link

SpiRaiL commented Feb 6, 2014

Thanks!

@mikaelpatel
Copy link

Actually I think it allows avoiding an erase cycle if the new value has the same "zero" bits and there are "one" bits in any place where the new value would require a change to "zero".

The erase cycle will force all bits to one (0xff) and then the new value is written.

Not clear if the eeprom_update_byte really does this as there is the below bug report:
http://savannah.nongnu.org/bugs/?38192

@matthijskooijman
Copy link
Collaborator

Seems that avr-libc only skips the entire write if the EEPROM byte is identical, it does not skip the erase when it is not strictly needed:
http://svn.savannah.nongnu.org/viewvc/trunk/avr-libc/libc/misc/eeupd_byte.S?root=avr-libc&view=markup

Switching to update does makes sense if only for the "do not write if the value already matches" (and the bug you linked will eventually be fixed, I'd expect). However, it seems that the current toolchain offers avr-libc 1.6.4 and the eeprom_update_byte function wasn't released until 1.6.7.

@leomil72, could you update your pullrequest (just commit --amend and force push) to only use update #if __AVR_LIBC_VERSION__ >= 10607?

@ffissore ffissore added New and removed New labels Feb 27, 2014
@cmaglie cmaglie added feature request A request to make an enhancement (not a bug fix) Library: EEPROM The EEPROM Arduino library Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) and removed Component: Core Related to the code for the standard Arduino API labels Apr 15, 2015
@Chris--A
Copy link
Contributor

The EEPROM library now provides an update method. EEPROM.write() still uses eeprom_write_byte.

EEPROM.put() uses the upadte() method to write its data.

@facchinm
Copy link
Member

facchinm commented Jul 6, 2015

Fixed with bed78fd

@facchinm facchinm closed this Jul 6, 2015
@ffissore ffissore added this to the Release 1.6.6 milestone Jul 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) feature request A request to make an enhancement (not a bug fix) Library: EEPROM The EEPROM Arduino library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants