Shop OBEX P1 Docs P2 Docs Learn Events
EEPROM write-read I2C suggestions ... but I am out of cogs — Parallax Forums

EEPROM write-read I2C suggestions ... but I am out of cogs

courtenscourtens Posts: 101
edited 2014-06-24 17:29 in Propeller 1
I need to store 30 words (number values in the range of 0-5000) to the on-board EEPROM. I found this related thread, but there is always a cog required. My problem is, I am out of cogs.

So now I am considering to "import" a I2C object into my main cog, hopping that there will be no naming convention collisions.

Is there a simple stripped down I2C object anyone recommends?

I had a look at pasm_i2c_driver.spin, but I don't know what value to set SCL and devSel to.
PUB WriteWord(SCL, devSel, addrReg, data) 

Comments

  • JonnyMacJonnyMac Posts: 9,105
    edited 2014-06-24 12:55
    I've attached my Spin-only EEPROM and I2C objects -- very simple. Used all the time in commercial apps.

    So now I am considering to "import" a I2C object into my main cog, hopping that there will be no naming convention collisions.

    Spin's use of dot notation (object.method) means you won't have any naming issues.
  • courtenscourtens Posts: 101
    edited 2014-06-24 13:57
    Thank you Jon!

    I thought I needed to start a new cog with the object started in it to start use the dot notation naming convention. Is this not so?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-06-24 14:33
    The dot notation pertains to objects, not cogs. The two are not the same, and you do not need to start a new cog for each object.

    -Phil
  • courtenscourtens Posts: 101
    edited 2014-06-24 16:26
    Does anyone have a sample file for super-dumb dummies? Somehow I just can't get it to work.

    Do I need to call jm.start(device) first? And how, or as what, would do I need to declare "device"?
    OBJ                                                                                                      
      jm : "jm_24xx256" 
    
    PUB Go
      jm.wr_word($7000, 1234)
    
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-06-24 16:39
    Yes, you need to call jm.start(0) first to access the boot EEPROM.

    -Phil
  • courtenscourtens Posts: 101
    edited 2014-06-24 17:20
    Thank you so much. Thant was just what was needed.
  • JonnyMacJonnyMac Posts: 9,105
    edited 2014-06-24 17:29
    Here's a tip that may be useful: If you want to preserve a variable between reset/power cycles you can do this:
    ee.wr_long(@somevariable, somevariable)
    


    Of course, you have to use the method appropriate for the variable type. By writing into the EEPROM at the location the variable lives in RAM, it will be auto-loaded after the next reset -- no read to call a read method.
Sign In or Register to comment.