Hello,
Can anyone kindly suggest a way to store and retrieve Float and Double Values into EEPROM. Thanks for the help.
Girish
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
Can anyone kindly suggest a way to store and retrieve Float and Double Values into EEPROM. Thanks for the help.
Girish
Hi,
Use an union composed from an uint32_t and a float. Write the union with float and then use library functions with uint32_t to write/ retrive them.
Some posters will protest against, portability problems, but (hope) will not be the case here.
For doubles - you got the picture - but do not mix with floats, since you do not have criteria to differentiate them.
ProgramEE( void *dat, uint32_t offset, uint32_t bytes)
{
(void)EEPROMProgram(dat, offset, bytes);
}
void asdf(void)
{
double x=3.0;
ProgramEE(&x, 12, sizeof(x))
}
From memory for EEPROMProgram.
The original EEPROMProgram should have been written with a void * argument not a unit32_t * argument. It's an outstanding bug in TivaWare. Easily fixed by a header file change (it even still matches what's in ROM).
A full version of above could/should include checks for sizes etc.. to meet the limitations of storage.
Robert
Dear Robert,
Thanks for your suggestion. Sorry...Took some time to follow the code. Now its working Fine and exact. Thanks for the help.
Regards,
Girish.