Shop OBEX P1 Docs P2 Docs Learn Events
i2cobject — Parallax Forums

i2cobject

christopherchristopher Posts: 31
edited 2006-07-27 20:21 in Propeller 1
Hi,

I built the 3 transistor serial programming adapter and it works successfully.

However when I run the i2cobject the 'init' function identifies the eeprom at p29 and p28 but I am not able to read from the eeprom. Also, I the test for ackbit appears to be not working. i note that the sda line is oulled up to 5v thru 4.7k. Do I need to pull up the scl line also ? Any assistance will be appreciated. The i2cobject was obtained from the parallax site by Javalin/ Jim Burrows.


Thank You

Christopher·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-17 15:20
    I've modified the i2cObject to actively drive the clock line when the i2c device is on pins 28 & 29. Please see the archive "TestPaged" at the end of this thread <http://forums.parallax.com/forums/default.aspx?f=25&m=135261&gt; for a program that reads the boot eeprom. There are also some methods in the main file that can be used to write to the boot eeprom to save values between resets. I believe the test for ackbit is working, but it's only returned on a write. You have to use the function "getLastAckBit" to see what it was on the last read.

    If you do add a pullup to 3.3V on the scl line (not 5V!), you can use the unmodified i2cObject.
  • FruttenboelFruttenboel Posts: 7
    edited 2006-07-17 17:13
    Christopher:

    > Do I need to pull up the scl line also ?

    Yes, definitely. I2C chips relie on open collector bus signals. The Propeller uses 3.3 Volts. But I2C is specified at 5 Volts.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vriendelijke groeten,

    Jan Verhoeven
    http://fruttenboel.verhoeven272.nl
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-07-17 17:36
    Ok, if I understand you correcty, Mike, the i2c hardware (with or without the pullups) causes the i2c software to operate differently. Is this correct?
    WHen I made my dev system, I included the pullups (as well as 2 other chips on the same i2c lines) so I would have a complete i2c subsystem.
    I'm currently using an older (from the object exchange) version of the i2c object, and it seems to work fine.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • christopherchristopher Posts: 31
    edited 2006-07-17 18:03
    Many thanks for the quick response. I will try suggestions.

    regards

    Christopher
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-17 18:16
    KK,
    The demo board was built without a pullup on the boot eeprom clock line. This isn't a problem for the boot process since the boot routines in the Propellor ROM actively drive the clock line both HIGH and LOW. It does cause standard I2C routines to fail (unless they also drive the clock line both HIGH and LOW). I just added some code to the library i2cObject that checks for the clock pin being 28 and, if so, actively drives the clock line (rather than relying on a pullup).

    Jan,
    I2C chips can be specified for a variety of voltages. There are some that require 5V and others that work fine at 3.3V. Phillips has some excellent information in their I2C specification that discusses how to mix 5V and 3.3V devices in a system. Most EEPROMs work fine at 3.3V and, if you don't have a mixed system, only require a pullup to 3.3V.
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-07-17 21:27
    Mike;
    Thanks for the info...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • JavalinJavalin Posts: 892
    edited 2006-07-19 20:55
    Chaps,

    Thanks, Mike for the heads up with the dev board not having pull-ups - I have my own so didn't twig that one.

    I've made a change to the i2cObject (now version 1.3) to allow you to init the object with a TRUE to pull-up and FALSE to not.

    Its been posted on the object library.

    James
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-20 05:14
    James,
    I don't see the i2cObject in the Object Library. Is it under some other name? Does the update need to be done manually by Parallax? I would like to switch to using your "standard" version for my programs.
    Mike
  • JavalinJavalin Posts: 892
    edited 2006-07-20 09:11
    Mike,

    mmm. Well i've updated the object library - I guess Parallax haven't got arround to approving it yet.

    I'll check again at the end of the day - sure it'll be done then!

    Thanks,

    James
  • JavalinJavalin Posts: 892
    edited 2006-07-20 19:08
    Mike,

    The Parallax website seems to have died, and the object hasn't been posted so i've attached for you.

    James


    Post Edited (Javalin) : 7/27/2006 8:18:52 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-20 19:45
    Thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-27 04:19
    I finally got around to testing the new version (1.3) and it doesn't seem to work with my demo board while the changes I made (see message above) do work on my system. I haven't had the time to figure out why yet. I do a "devicePresent" right after I call "init". With my modified version 1.2, the devicePresent call returns true while with version 1.3, it returns false.
  • JavalinJavalin Posts: 892
    edited 2006-07-27 12:48
    Hi Mike,

    Have you set the object on the init to have (_i2cSDA, _i2cSCL, TRUE)??

    Does it work if you comment out the:
    if driveSCLLine == false
    ' dont do this if the SCL line is not pulled up with a resistor.
    ' as the line will stay in the last state
    repeat until ina[noparse][[/noparse]i2cSCL] == _pinHigh

    bit in the i2cStart function?

    James
  • NewzedNewzed Posts: 2,503
    edited 2006-07-27 12:58
    I am also having a problem with this object.· I initialized with:

    i2cSDA, _i2cSCL, TRUE

    but apparently the program is either not writing to the EEPROM or reading the EEPROM.· I had no problem with V1.2 using my old Propeller board, but when I switched to the Demo board and V1.3 it wouldn't work.· There is just no way I can add a pullup resistor to the Demo board.· I thought about setting another pin high and using that to pull uo the SCL line but I don't have any spare pins.· Perhaps I could use on of the pins for the mouse since I'm an not using those pins.· Then I could go back to V1.2.

    Sid
  • NewzedNewzed Posts: 2,503
    edited 2006-07-27 13:08
    Is the SCL line just one-way - Prop to EEPROM?· Maybe I could just set P28 high - would that work?

    Sid
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-27 13:43
    James, I took my main program (that failed with 1.3), took out the ",true" in the call to "init" and recompiled it with the modified 1.2 version. The result worked. About the start function part that skips the check of SCL, that's what I have in my routine and where it was hanging up on the boot EEPROM in the original version 1.2.

    Sid, the SCL line is just one-way and setting P28 high rather than to input is what you have to do, but there are several places in the code where it's done and you do need to change all of them.
  • NewzedNewzed Posts: 2,503
    edited 2006-07-27 15:35
    Mike, my old Prop board had a pullup on the SCL line.· If I go back to V1.2 and set P28 high, would that do the trick with the Demo board?

    Sid
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-27 16:10
    Sid, version 1.2 works fine with any Prop board that has pullups on both SCL and SDA. The problem is with the demo board SCL line which doesn't have a pullup. Just setting P28 high in your code won't fix the problem since the v1.2 i2cObject code changes "dir[noparse][[/noparse]SCL]" to zero and sets "outa[noparse][[/noparse]SCL]" to zero in anticipation of setting "dir[noparse][[/noparse]SCL]" to one later.

    Until the 1.3 version gets fixed, I suggest you use my modified 1.2 version that specifically checks for SCL == 28 and actively drives SCL both high and low.
  • JavalinJavalin Posts: 892
    edited 2006-07-27 20:21
    Mike, all,

    Try this one.· I've just been testing it with and without an SCL line pull-up on the PDB.· I've removed the i2cBits parameter from the i2cRead function as it was not being used!

    Note :- you MUST have a pullup on the SDA line!

    Sorry for the hassle.

    James
Sign In or Register to comment.