Hi, I want to save a Ulong Variable (06 digits) in EEPROM, any example for me.?
I get a code from Arduino forum, writing in the eeprom memory locations is ok, but when i tried to get back data from these locations variable only show the value less then 65000. mean only get back Unint value from eeprom. any help pleas...
long EEPROMReadlong(long address) {
long four = EEPROM.read(address);
long three = EEPROM.read(address + 1);
long two = EEPROM.read(address + 2);
long one = EEPROM.read(address + 3);
return ((four << 0) & 0xFF) + ((three << & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
}
void EEPROMWritelong(int address, long value) {
byte four = (value & 0xFF);
byte three = ((value >> & 0xFF);
byte two = ((value >> 16) & 0xFF);
byte one = ((value >> 24) & 0xFF);
EEPROM.write(address, four);
EEPROM.write(address + 1, three);
EEPROM.write(address + 2, two);
EEPROM.write(address + 3, one);
}
How to save ULong variable value in EEPROM?
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: How to save ULong variable value in EEPROM?
Hello,
Maybe try this instead.
Read
Write
Maybe try this instead.
Read
Code: Select all
byte four = EEPROM.read(address);
byte three = EEPROM.read(address + 1);
byte two = EEPROM.read(address + 2);
byte one = EEPROM.read(address + 3);
return = one
return = return << 8
return = return | two
return = return << 8
return = return | three
return = return << 8
return = return | four
Code: Select all
byte four = value;
value = value >> 8;
byte three = value;
value = value >> 8;
byte two = value;
value = value >> 8;
byte one = value;
EEPROM.write(address, four);
EEPROM.write(address + 1, three);
EEPROM.write(address + 2, two);
EEPROM.write(address + 3, one);
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: How to save ULong variable value in EEPROM?
hi,
How to write this in calculation block?
EEPROM Read;-
return = one
return = return << 8
return = return | two
return = return << 8
return = return | three
return = return << 8
return = return | four
EEPROM Write :-
byte four = value;
value = value >> 8;
byte three = value;
value = value >> 8;
byte two = value;
value = value >> 8;
byte one = value;
Please help me...
How to write this in calculation block?
EEPROM Read;-
return = one
return = return << 8
return = return | two
return = return << 8
return = return | three
return = return << 8
return = return | four
EEPROM Write :-
byte four = value;
value = value >> 8;
byte three = value;
value = value >> 8;
byte two = value;
value = value >> 8;
byte one = value;
Please help me...
- Attachments
-
- Flow1.JPG (11.87 KiB) Viewed 3321 times
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: How to save ULong variable value in EEPROM?
Hi Sashinda,
Welcome to the forums.
I have attached a flowchart that works the way Ben suggested.
I have also included two alternative ways of saving and retrieving ULongs(disabled icons).
Welcome to the forums.
I have attached a flowchart that works the way Ben suggested.
I have also included two alternative ways of saving and retrieving ULongs(disabled icons).
- Attachments
-
- Store & Retrieve ULong within EEPROM v3.fcfx
- (14.77 KiB) Downloaded 218 times
Martin
Re: How to save ULong variable value in EEPROM?
hello...Medelec35
It's working super...
Thanks a lot.
I will never forget your help...
It's working super...
Thanks a lot.
I will never forget your help...
Last edited by Sashinda on Thu Sep 03, 2020 7:24 pm, edited 1 time in total.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: How to save ULong variable value in EEPROM?
Hi Sashinda ,
You're welcome.
I'm pleased you have your project working super.
Thank you for letting us know, really appreciate it.
You're welcome.
I'm pleased you have your project working super.
Thank you for letting us know, really appreciate it.
Martin
- AbhijitR
- Posts: 299
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 280 times
- Been thanked: 79 times
- Contact:
Re: How to save ULong variable value in EEPROM?
Hello! Martin
Many thanks for this post, you are too good.
Abhi
Many thanks for this post, you are too good.
Finally I got the opportunity to thank you.
Abhi