thijse / Arduino-EEPROMEx

Extended EEPROM library for Arduino
Other
170 stars 54 forks source link

Work around problem in <avr/eeprom.h> #31

Open SpenceKonde opened 4 years ago

SpenceKonde commented 4 years ago

At least as of the avr-gcc package Arduino is distributing as 7.3.0-atmel3.6.1-arduino5 (with latest megaAVR board package, 1.8.5), for megaavr parts, eeprom_is_ready() is defined as:

# define eeprom_is_ready()  bit_is_clear (NVM_STATUS, NVM_NVMBUSY_bp)

Those registers do not exist, at least on the megaAVR 0-series (ATmega4809/4808 and smaller flash versions), tinyAVR 0-series or tinyAVR 1-series parts. They meant to check the EEBUSY bit in the NVMCTRL.STATUS register. I don't know who to submit fixes for eeprom.h to, but this change works around the bug in this library, so this will work on megaavr parts (Nano Every, Uno WiFi Rev. 2, and the ATtiny parts, which are supported by https://github.com/SpenceKonde/megaTinyCore)

avandalen commented 4 years ago

The problem is solved, I think, when we use the standard library EEPROM.h in C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\EEPROM\src\EEPROM.h

instead of AVR Libc EEPROM.h here: https://github.com/Patapom/Arduino/blob/master/Libraries/AVR%20Libc/avr-libc-2.0.0/include/avr/eeprom.h Where is this library located on my PC? I can’t find it.