save and read 16 bit numbers to EEPROM

General discussion on IDE.
Post Reply
Author
Message
cmrelectrical
Posts: 19
Joined: 29 Dec 2020 12:06

save and read 16 bit numbers to EEPROM

#1 Post by cmrelectrical » 09 Jan 2021 21:05

Hi
I,m new to C, I have an unsigned 16 bit number maximum 1000 generated from a VTFT. progress bar. I know how to save, code below and read an 8 bit numbers, but can see anything useful on how to save 16 bit numbers to EEPROM, then get the number back from EEPROM and reassemble both bytes back into a 16 bits.
EEPROM_Write(0x05,ProgressBar3.Position);
Delay_ms(20);

Any suggestions would be much appreciated :D

Hristo
Posts: 33
Joined: 20 Oct 2014 14:39

Re: save and read 16 bit numbers to EEPROM

#2 Post by Hristo » 10 Jan 2021 12:41

Code: Select all

Unsigned Int N;
EEPROM_Write ( Addr, Hi ( N ));
EEPROM_Write ( Addr+1, Lo ( N ));
...
N = EEPROM_Read ( Addr ) * 256 + EEPROM_Read ( Addr+1);



cmrelectrical
Posts: 19
Joined: 29 Dec 2020 12:06

Re: save and read 16 bit numbers to EEPROM

#3 Post by cmrelectrical » 19 Jan 2021 17:44

Hi Hristo
Just got round to trying your code. Obviously it worked, this has saved me hours of research so all I can say is....Thank You :D :D

Post Reply

Return to “IDE General”