i2c EEProm not saving data
davidpzk
Posts: 19
Hi friends. I just started learning the Propeller platform a few weeks ago. While I already have made the Propeller do alot of fun stuff, I need help solving a stange problem. It seems I cannot write to an EEPROM.
I am using the Gadget Gangster USB platform to do this test and the object I am tring to use is the I2C_ROMEngine.
I wanted to confirm I understood how to use this object so I wrote some simple code to store a value into a EEProm register and then retrive it.
I upload the code into EEPROM and run it
The terminal screen successfuly displays the value >>>123<<<, obviously storing the value into the EEProm then recalling it.
To double test this, I then upload the following code into RAM (not the EEPROM). Its the same code as above but I comment out the line that saves data to the EEPROM.
At this point I am only interested in reading EEPROM data that was put in the EEPROM using the code above.
What am I doing wrong?
I am using the Gadget Gangster USB platform to do this test and the object I am tring to use is the I2C_ROMEngine.
I wanted to confirm I understood how to use this object so I wrote some simple code to store a value into a EEProm register and then retrive it.
I upload the code into EEPROM and run it
CON _clkmode = rcfast OBJ RomEngine: "I2C_ROMEngine" term : "Parallax Serial Terminal" PUB Main term.Start(9600) RomEngine.ROMEngineStart (29, 28, 0) '(dataPinNumber, clockPinNumber, lockNumberToUse) term.str(string("hello",13)) waitcnt (10000000+cnt) term.str(string("writing 123 to eeprom memory location 7080",13)) RomEngine.writeByte(7080, string("123")) '(EEPROMaddress, value) waitcnt (10000000+cnt) term.str(string("pausing just incase", 13)) waitcnt (10000000+cnt) term.str (string("reading from memory location 7080", 13)) term.str (string(">>>")) term.str (RomEngine.readByte(7080)) term.str (string("<<<"))
The terminal screen successfuly displays the value >>>123<<<, obviously storing the value into the EEProm then recalling it.
To double test this, I then upload the following code into RAM (not the EEPROM). Its the same code as above but I comment out the line that saves data to the EEPROM.
At this point I am only interested in reading EEPROM data that was put in the EEPROM using the code above.
CON _clkmode = rcfast OBJ RomEngine: "I2C_ROMEngine" term : "Parallax Serial Terminal" PUB Main term.Start(9600) RomEngine.ROMEngineStart (29, 28, 0) '(dataPinNumber, clockPinNumber, lockNumberToUse) term.str(string("hello",13)) waitcnt (10000000+cnt)) 'term.str(string("writing 123 to eeprom memory location 7080",13)) 'RomEngine.writeByte(7080, string("123")) '(EEPROMaddress, value) waitcnt (10000000+cnt) term.str(string("pausing just incase", 13)) waitcnt (10000000+cnt) term.str (string("reading from memory location 7080", 13)) term.str (string(">>>")) term.str (RomEngine.readByte(7080)) term.str (string("<<<"))The end result is >>><<< which means there is nothing stored in the EEProm.
What am I doing wrong?
Comments
In the first code, it reads back the location and prints the string to the terminal. Since "123" is no longer at that location in your second code. It's probably trying to display some unprintable ASCII character.
Try adding this to the bottom of your code:
EDIT: This is wrong. I'm fixing it now. Not fixed yet, sorry.
Then instead of using:
In your first code, use:
Edit again: Sorry this wont work either. The location of testString will change between the two programs. I've got to go. If someone else hasn't helped you, I'll help later.
And you really should be writing and reading a word to the EEPROM since memory location can be higher that 255 (the limit of one byte).
Or you could try the following program (attached) I created by modifying the Monitor object Chip Gracey wrote. It will let you read/write individual EEPROM locations. I use this to troubleshoot EEPROM connections.
My EEPROM writing problem is still a mystery...
Here is the display of my terminal window showing that no data has been stored to the Gadget Gangster EEPROM
Start routine
writing 123 to eeprom memory location 8090
pausing just incase
reading from memory location 8090
>>><<<
So the EEPROM Monitor did not work for you either?
Most Prop systems have a 64kB eeprom and you can use the upper 32k for general storage...
That is very small and simple and easy to use.
Mike Green has a more versitile version in OBEX
Propeller Eeprom.spin (from the PE Kit Lab)
http://forums.parallax.com/showthrea...271#post678271
The EEPROM monitor/dump works amazingly well.
My problem is still not solved.
The Propeller Eeprom object only suppots copying from ram to rom and from rom to ram in a range of addresses. Thats not what I am trying to do here.
I would love to write a byte (just one little tiny byte) to a know location in the EEPROM, then successfully recall it.
We are getting off topic here.
Using the above code (which by all right should work). I cannot successfully write to an AT24C512. This is annoying, I can watch the Propeller Tool do a successful write but none of the i2c objects work.
Here is another simple sample using another i2c object that does not work. Im sure I am doing something wrong, but cant figure out what that might be.
I wanted to upload a small routine into the EEPROM that wrote to itself, then upload a different routine into RAM ONLY that would check the EEPROM and confirm that the former routine wrote to the EEPROM.
For whatever reason, this dosent work. Maybe someone can explain why...
Very weird...
It looks like kuroneko has you pointed in the right direction.
I personally use Propeller EEPROM for my EEPROM needs. Here's a little program to write and read a few bytes to EEPROM.
I loaded the above to EEPROM and ran the program. I then loaded the following to RAM only.
This is the output from the two programs.
I'm attaching the first program as an archive.
Your troubles in using "Basic_I2C" were caused in part by using incorrect parameter.
You've also been using the wrong data types in many of your programs. You originally were writing a memory location to EEPROM not what was stored in the memory location.
You might want to take a look at this thread.
It has a lot of good information about using Mike Green's Basic_I2C_Driver (including some examples by Mike).
kuroneko's corrections might make more sense after you read it.
David,
My goal in providing the example code was not to solve your problem but rather to provide an alternate means of verifying your EEPROM was able to be read/written properly by a known working object. Based on the name of the object you are using and my lack of familiarity with it I would not be able to provide details for that object. That object, by name, referenced ROM and I was trying to provide EEPROM access, which is what you wanted. At this point I will defer this to those who can help with the object you're trying to use. The only reference to the object I could find was the following thread where another member was also having issue reading/writing the EEPROM.
http://www.google.com/url?sa=t&rct=j&q=&esrc=s&frm=1&source=web&cd=1&ved=0CCAQFjAA&url=http%3A%2F%2Fforums.parallax.com%2Fshowthread.php%3F124857-Trouble-with-simple-RomEngine-and-TV.text-program.&ei=5mwQT_TFPOORiQLdx7W8DQ&usg=AFQjCNFekjwULFonWEBrE_AmGV3TZb_JOA&sig2=Jgk_StpuzvttKvz8Fh8oUQ