Pages: [1]   Go Down
Author Topic: EEPROM library  (Read 570 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I suspect that it I call EEPROM.write(addr) and addr is a number larger than the memory size, the higher order bits are just discarded.
Is it so?
Do you think it would it be nice to have a MAXEEPROMADDR constant defined as the last valid address, that would change depending on the board, so that I can write a code that runs on different arduinos, for instance the different versions of the NANO ?
Otherwise a small data logger, for instance, would destroy previously stored values.
What do you think ?
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12779
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I suspect that it I call EEPROM.write(addr) and addr is a number larger than the memory size, the higher order bits are just discarded.
Is it so?

Yes.

Quote
Do you think it would it be nice to have a MAXEEPROMADDR constant defined as the last valid address, that would change depending on the board, so that I can write a code that runs on different arduinos, for instance the different versions of the NANO ?

Put this at the top of your Sketch and you'll be good to go...

#define MAXEEPROMADDR E2END

Or, you can just use E2END.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 86
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just tried, it works. Thanks !
Is that E2END constand described somewhere in the reference ?
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 200
Posts: 12779
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.nongnu.org/avr-libc/user-manual/group__avr__io.html
Logged

Pages: [1]   Go Up
Jump to: