Shop OBEX P1 Docs P2 Docs Learn Events
i2c question — Parallax Forums

i2c question

btomkobtomko Posts: 10
edited 2008-06-26 23:09 in Propeller 1
I want to be able to connect a few 3.3v i2c devices to pins 28-29 (the same place as the eeprom).· I heard that the·i2c specification·requires a pullup resistor on SCL.· Will all i2c devices work when the propeller chip is driving SCL by itself without a pullup resistor.· I would imagine that the propeller boot loader would not work with a pullup resistor on SCL because rather than "high-low-high-low" it would be "hiZ-gnd-hiZ-gnd" to operate the clock.

Comments

  • Ken PetersonKen Peterson Posts: 806
    edited 2008-06-26 14:41
    A pullup on SDA necessary because both the host and the slave drive that line so it should be wired-or. As for the SCL line, it's good to have a pull-up so that when the bus goes idle and the host puts it in high-impedance, it keeps the line at a high logic level.

    After the Prop boot loader loads the program from the EEPROM, all pins go into high impedance as a default condition.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • btomkobtomko Posts: 10
    edited 2008-06-26 15:09
    Thanks Ken, but I was wondering that since all the wiring diagrams for the propeller show the EEPROM SCL on pin 28 as a straight connection with no pullup resistor, I think that if I connected a pullup resistor to pin 28 that the boot loader would not work since it would be setting the pin high and low to operate the clock signal rather than grounding it (for low) and then setting it high impediance (for high). Should I use a different pin other than 28 for the CLK signal using a pullup resistor for my other i2c devices?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-06-26 16:22
    As Ken states, it's always a good idea to have a pullup on SCL, so it will be in a high state when the system powers up and the pins are tri-stated. There are also some cases where a pullup on SCL is necessary for proper operation of the I2C bus:

    1. Multi-master busses, where more than one device has control of SCL.

    2. Single-master busses with slow slave devices that can exert a "bus hold" by asserting SCL low until they're ready for more data.

    In these situations, it's never proper to drive SCL high.

    -Phil
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-26 17:04
    You can always add a pullup on SCL if you want. 10K would work fine. The bootloader will not get confused. You can also attach additional I2C devices to the boot I2C bus like additional EEPROM or I/O expanders. Use a pullup in that case. The Propeller Protoboard does have both pullups.
  • btomkobtomko Posts: 10
    edited 2008-06-26 18:10
    Thanks guys for your help. Just one more question. When using a pullup resistor and having only one master device with no slow slave devices as Ken stated, in order to drive the clock high, is it best to set the output to high or to set the direction to input (so that it will be high impedance and the pullup resistor will drive the line high)? Thanks again for your help.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-26 18:16
    It depends on how fast you want to drive the bus, how long the bus is, and how many slaves are hooked up. If you're trying to use one of the faster modes (400KHz or 1MHz particularly), driving the bus actively will give sharper, faster signal transitions. If 100KHz is ok or 400KHz and there are only a few slave devices and the bus is only a few inches long, the pullup is fine.

    This kind of question rarely has a "best solution" answer. It depends on the circumstances and what you're trying to do.
  • David E.David E. Posts: 13
    edited 2008-06-26 21:43
    Mike what's the longest bus you have seen as far as wire length is concerned? I'm at six inches now but am worried about sensor placement as I might have a run of 24 inches or more between tachs and temp sensors.....Is it best to run a long loop or use a star topology to the devices?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-26 22:37
    I've personally only dealt with I2C bus lengths on the order of inches. There are some application notes and white papers on the Phillips website (now NXP) dealing with special considerations for I2C buses. Do some browsing.
  • TimmooreTimmoore Posts: 1,031
    edited 2008-06-26 23:09
    I have used up to about 24inches without problem. I did about a 6inch hop to a breakout board which then starred out to about 12 devices which were between 2inches to 18inches (2@2", 5@6" and 4@18" and a couple I dont remember) from the breakout board. Most of the devices were 5V, so I used a 3.3/5 I2C level shifter chip before the 1st hop.
Sign In or Register to comment.