Shop OBEX P1 Docs P2 Docs Learn Events
How to use Basic_12C_Driver or 12COject please??? — Parallax Forums

How to use Basic_12C_Driver or 12COject please???

whiteoxewhiteoxe Posts: 794
edited 2010-02-02 21:23 in Propeller 1
Hi All,

I have been reading Javlin notes on EEPROM usage without getting too far just yet. Even the wiring I am unsure of. Is it easier to connect my second 32k EEPROM to the one I have or use two new pins on the prop and if so should I NOT pullup SCL and or SDA (javlin notes pullup both with 4.7K R)? The Object notes I think say NO to answer my own question. I have SDA with a pullup on the EEPROM the prop uses for running code.

I need an example of how to use the code for a READ and WRITE. I dont understand much about this object. Thanks.

cry.gif

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-04 00:34
    How and where you connect additional EEPROM depends on what kind of board you have. If the leads from pins 28 and 29 are easily accessible, you could use those since they're already used for an I2C bus and already have a pullup on SDA (and maybe SCL). If they're not easily accessible, use any even/odd pair of I/O pins that are convenient. The SDA pin has to have a pullup (4.7K is a good choice, but it's not too critical) and the SCL pin pullup is optional (I'd put it in if convenient).

    The Basic_I2C_Driver is straightforward to use, has some simple examples in the comments. Remember that there needs to be a 5ms delay after writing to the EEPROM.· There's a WriteWait routine that shortens this time by checking the EEPROM for a response which comes when it's done with its write cycle.

    If you connect a 2nd EEPROM to pins 28/29, make sure to change the address pins of the new EEPROM to something other than all zero bits.

    Post Edited (Mike Green) : 11/4/2009 12:39:23 AM GMT
  • whiteoxewhiteoxe Posts: 794
    edited 2010-02-02 12:32
    Mike Green.... I could not follow your examples what few there were, well actualy none i could find. You must be far smarted than.

    The Basic_I2C_Driver is straightforward to use, has some simple examples in the comments <-- i didnt see any.

    Would have been very helpful to me if you understood my lack of being able to understand or i wouldnt have asked for help.


    I need an example of how to use the code for a READ and WRITE. I dont understand much about this object. Thanks.
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-02-02 12:48
    '' PRI writeIt | startTime
    ''   if i2c.WritePage(i2c#BootPin, i2c#EEPROM, eepromAddress, @buffer, 32)
    ''     abort ' an error occured during the write
    ''   startTime := cnt ' prepare to check for a timeout
    ''   repeat while i2c.WriteWait(i2c#BootPin, i2c#EEPROM, eepromAddress)
    ''     if cnt - startTime > clkfreq / 10
    ''       abort ' waited more than a 1/10 second for the write to finish
    
    

    That's the code to write and there is code for read just a few lines above, both included in the Basic_I2C_Driver.spin. And please make sure you read and understand the comments below that.

    Usually ALL objects contain demo-code that uses the object. Up to now I did not find any object that needed additional explination and were running right out of the box.

    If you still have problems feel free to ask again, that's what the forum is good for.
    ·
  • JavalinJavalin Posts: 892
    edited 2010-02-02 13:18
    whiteox,

    Look at the i2cDemoApp.spin file in the i2cObject zip file. Its got a full set of example's of all the sub-objects (eeprom read & write, temperature, motor control etc) and a wiring diagram in the top of the file.


    >it easier to connect my second 32k EEPROM to the one I have or use two new pins on the prop
    yes.· Change the address of the second EEPROM - typically this is done by connecting the address pins to +5v or GND.· Each device on the bus must have a unique address.

    >I NOT pullup SCL and or SDA
    as Mike was saying - it depends what board your using - i.e. a Propeller demo board, or Propeller Professional Dev board, etc. If its a·Parallax one then they have the·schematics on their website for·the boards - have a look.· If·its·your own/other then SCL/SDA lines need one pull up each of approx 4.7k to +3.3v.

    >I have SDA with a pullup on the EEPROM the prop uses for running code.
    No - the bus needs a pull up - not each device.· Kinda link turning the tap on on the hose - you only need to do it once.

    James

    Post Edited (Javalin) : 2/2/2010 9:29:29 PM GMT
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-02-02 13:38
    Javalin said...
    typically this is done by connecting the address pins to +5v or GND
    It's propably better to tie these to 3.3V as well ... not to 5V
  • JavalinJavalin Posts: 892
    edited 2010-02-02 13:41
    true - but depends on the device I'd suspect. You can run +5v devices on the bus with the +3.3v I've found.
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-02-02 13:53
    Yep ... it won't harm the propeller, as the prop connection is open collector and if the pullup is high enough you could even tie this to 5V. But when I remember correctly it can be a problem to have a chip running at 3.3V and a input pin directly connected to 5V. I just mentioned it because unexperienced users might simply do what you suggest ...
  • whiteoxewhiteoxe Posts: 794
    edited 2010-02-02 21:23
    THANKS FOR THE EXTRA HELP,

    mIKE.
Sign In or Register to comment.