Shop OBEX P1 Docs P2 Docs Learn Events
EEPROM help please. — Parallax Forums

EEPROM help please.

Filip SFilip S Posts: 54
edited 2006-11-22 20:49 in Propeller 1
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.

Comments

  • JavalinJavalin Posts: 892
    edited 2006-11-15 21:37
    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 SFilip S Posts: 54
    edited 2006-11-15 21:41
    Thanks Javalin!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)
  • JavalinJavalin Posts: 892
    edited 2006-11-15 21:42
    Welcome.
  • Filip SFilip S Posts: 54
    edited 2006-11-20 20:19
    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.)
  • JavalinJavalin Posts: 892
    edited 2006-11-20 20:35
    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 SFilip S Posts: 54
    edited 2006-11-20 20:40
    Thanks!
    It seems like it works now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)
  • Filip SFilip S Posts: 54
    edited 2006-11-21 18:26
    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.)
  • JavalinJavalin Posts: 892
    edited 2006-11-21 18:29
    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 SFilip S Posts: 54
    edited 2006-11-22 19:35
    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.)
  • JavalinJavalin Posts: 892
    edited 2006-11-22 19:58
    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 SFilip S Posts: 54
    edited 2006-11-22 20:02
    That's what I did, but no result.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)
  • JavalinJavalin Posts: 892
    edited 2006-11-22 20:23
    Can you post your code?
  • Filip SFilip S Posts: 54
    edited 2006-11-22 20:29
    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.)
  • JavalinJavalin Posts: 892
    edited 2006-11-22 20:44
    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 SFilip S Posts: 54
    edited 2006-11-22 20:49
    Thanks for the tip James!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out my game page: http://maze3d.no-ip.org (Swedish only, sorry.)
Sign In or Register to comment.