storing data in EEPROM
shmow
Posts: 109
Hey All,
I'm using Mike Green's Minimal_I2C_Driver (Basic_I2C_Driver - http://obex.parallax.com/objects/26/ . (Thanks Mike!)
I'm trying to understand it, but I'm not sure how to handle devSel or addrReg. What would I put in those variables?
I have the microchip 24LC256 - so, is that device 2 for devSel?
And, addrReg is anywhere from $0000 (0) to $3FFFF ((26000)?
Am I understanding this correctly?
Regards,
Shmow
I'm using Mike Green's Minimal_I2C_Driver (Basic_I2C_Driver - http://obex.parallax.com/objects/26/ . (Thanks Mike!)
I'm trying to understand it, but I'm not sure how to handle devSel or addrReg. What would I put in those variables?
I have the microchip 24LC256 - so, is that device 2 for devSel?
And, addrReg is anywhere from $0000 (0) to $3FFFF ((26000)?
Am I understanding this correctly?
Regards,
Shmow
Comments
here's an attempt to store the value 255 in an EEPROM address (not really sure if it works).
And, an attempt to retrieve what may be in that address too...
If you can decipher what I'm trying to do here then throw me a line cause I'm way in over my head!
Cheers,
Shmow
In Mike's driver there are read/write examples in the comments.
An EEPROM device id is $A0 ... that's what you get with i2c#EEPROM.
The address range of a 24LC256 is $0000 to $7FFF ... Not sure what $3FFFF will give you.
To store 255 in location 0 you say buffer[noparse][[/noparse]0] := 255 ... but you should read the buffer first.
So a call to Mike's readIt method would preceed that.
Here's a simple, but untested example that should work barring syntax errors, etc....
Hope this helps some way.
--Steve
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM
thanks a'plenty for the helpful reply. I'll run with this to see if I can get things in order.
Cheers,
Shmow
I tested out what you gave me, and I actually got the EEPROM to store my value.
The problem is that when the power is lost and restored, the value is not there in the EEPROM.
Isn't there a way to store a value that won't be lost when the power is interrupted?
Regards,
Shmow
Here's my code with your suggestions:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM
I did the same thing for the readit method too, and it works!
Thanks for your help.
Here's the final sample code for anyone else following:
Cheers,
Shmow
Just be careful with that:
Let's say it takes about 40 instruction to execute it. 20 instructions is 20*12.5ns = 0.25us.
If you keep your finger for 1sec on the button, you will execute this loop 4000 times.
An EEPROM can write about 1 000 000 times a value. Then you can have failures and you will have to replace it. So 1 000 000 / 4 000 = 250...
So if you try your program more than 250 times, you will burn your EEPROM.
Just update your code with that:
Just be aware that this will old this cog until you release the button. For my onw project, I have a single cog to handle the inputs, so it's not olding anything on the other cogs.
JM
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Linux? There is worst, but it's more expensive.