PDA

View Full Version : EEPROM help please.



Filip S
11-16-2006, 04:27 AM
I've been trying to use the I2C LowLevel object to interface with the main EEPROM on the demo board, so that I could save some data until the next time the propeller boots up. The problem is that i don't get it to work with that object, when i call i2cstart , it stops execution. And then when i tried to·send the data (without calling i2cstart)·0,1,1,0 and then recived the next eight bits, i got the result $FF.·Can someone please·help me?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)

Send me a message if you want me to translate it.

Javalin
11-16-2006, 04:37 AM
Filip S,

For the demo board's you have to pass "drivelines" as true when you initialize the i2cobject, as the board does not have a pull'up on the i2c clock line. I.e. (from the i2cDemoApp.spin)

' setup i2cobject
i2cObject.Init(i2cSDA, i2cSCL, true)

james

Filip S
11-16-2006, 04:41 AM
Thanks Javalin!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)

Javalin
11-16-2006, 04:42 AM
Welcome.

Filip S
11-21-2006, 03:19 AM
Should I get $FF in y in the following program?
If not, please tell me what's wrong. I'm quite sure that byte 1 in the EEPROM isn't $FF.
obj
x : "i2cObject"

pub main | y
x.start
x.init(29,28,true)
y := x.readlocation(0,1,16,8)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)

Javalin
11-21-2006, 03:35 AM
Filip,

You're not passing the EEPROM address. The format of the command (for eeproms)·is:



eepromData := i2cObject.readLocation(EEPROM_ADDRESS, EEPROM_LOCATION, 16,8)


so for your program and an EEPROM on the default address of 160 / %1010_0000 / A0 (decimal, bin, hex),



y := x.readlocation($A0,1,16,8)


would return the byte·at address·1 in the EEPROM.

Have a look at the "i2cDemoApp" in the i2cObject library - it has an EEPROM_DEMO function which shows this in action.

James

James

Post Edited (Javalin) : 11/20/2006 8:53:40 PM GMT

Filip S
11-21-2006, 03:40 AM
Thanks!
It seems like it works now.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)

Filip S
11-22-2006, 01:26 AM
It works when I read data from the EEPROM, but not to write data.
I use the .writelocation(%1010_0000,1,"Z",16,8) (after initialization)·and I think I'm doing as in the example.
It doesn't seem like it's working there either, pleas help me.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)

Javalin
11-22-2006, 01:29 AM
Filip S,

Try .writelocation(%1010_0000,1,90,16,8)

90 is the ASCII code for "Z".

Cannot remember how (if) the propeller changes ASCII-DEC. Anybody?

James

Filip S
11-23-2006, 02:35 AM
I've tried to edit the demo program that writes to the EEPROM, so that it should write to the first 1000 locations with 0. But when I press reset the propeller starts the program I previously loaded into the eeprom. So it doesn't work there either. Any idea about the problem?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)

Javalin
11-23-2006, 02:58 AM
Filip S,

Well all you should need to do is change the counters from 0..10 to 0..1000 on the EEPROM_DEMO function and that works to clear the EEPROM

James

Filip S
11-23-2006, 03:02 AM
That's what I did, but no result.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)

Javalin
11-23-2006, 03:23 AM
Can you post your code?

Filip S
11-23-2006, 03:29 AM
Here
Watch the function SaveEEPROM, there it first checks the eeprom if the program is loaded into it, if so it saves the highscorelist to the right locations in the eeprom so that theyr'e loaded by the prop. at startup. Use a vga and a keyboard to run the game once (so you get something in the highscore) and then select Save Highscore.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)

Javalin
11-23-2006, 03:44 AM
Filip S,

Had a quick look - but I'd simplify it if I were you. Use a new program and the i2cObject, modify the eeprom_demo to prototype the save code, then build it into your program when you know thats working.

James

Filip S
11-23-2006, 03:49 AM
Thanks for the tip James!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)