Storing Decimal Value in Eeprom?
Carl Lawhon
Posts: 36
Is there any way I can store a decimal value in the eeprom? For example, how could I store something like 123.456?
Comments
The above examples require some modification when used with James code. In my code the 8 stands for the number of bytes to send.
I probably haven't answered your question directly but this is a way to store two longs in memory.
John Abshier
You can go even fancier by assigning other unused values, like - to $B and E to $E. So a scientific number like -1.74E-6 would be $B1, $A7, $4E, $B6, $F0. The last digit is a "don't care", it's just padding to make the number take 8 bits.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Post Edited (Paul Baker) : 1/7/2009 1:39:58 AM GMT
Carl Lawhon
1) The 4 bytes of the long have to fit in an EEPROM "page". The best way to do this is simply to require the EEPROM address to be a multiple of 4.
2) A write operation takes roughly 5ms. You can put in a 5ms wait like WAITCNT(CLKFREQ/200+CNT) or you can use the test for completion of the write that's shown in the comments at the beginning of the driver.
3) The pin # of the SCL signal can be specified separately or combined with the EEPROM address as described in the comments. The pin # of the SDA signal is always the next pin.
object is at link
obex.parallax.com/objects/30/
Post Edited (grasshopper) : 1/7/2009 8:47:20 PM GMT