Shop OBEX P1 Docs P2 Docs Learn Events
so... why do it this way? — Parallax Forums

so... why do it this way?

CannibalRoboticsCannibalRobotics Posts: 535
edited 2010-10-14 22:07 in Propeller 1
So I was poking around looking at different ways to handle I2c communication in SPIN and PASM and I ran accross this in Kwabena W. Agyeman's EEPROM driver. It works but under the repeat it's only changing port direction for each bit.
Its clever in that it is essentially functioning as an open-collector port. Neat-O! But Why?
Obviously there is a little speed improvement?
But any electronic advantage? Ports are still theoretically limited to 3.3 +-0.3v, 40mA (even though many have successfully violated that limit). Is it purely to accomidate the pull-ups speced for the SDA and SCL lines?
Hummm.

PRI transmitPacket(value) ' 4 Stack Longs
value := ((!value) >< 8)
repeat 8
dira[dataPin] := value
dira[clockPin] := false
dira[clockPin] := true
value >>= 1

dira[dataPin] := false
dira[clockPin] := false
result := not(ina[dataPin])
dira[clockPin] := true
dira[dataPin] := true

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-10-14 12:43
    The data pin must always be driven open-drain to avoid bus conflicts; i.e. you don't want to drive the pin high while the slave device is pulling it low. In most cases this is not necessary with the clock pin, but there are exceptions: 1) multi-master systems, and 2) master-slave systems where the slave device has a "clock hold" capability.

    -Phil
  • RaymanRayman Posts: 14,889
    edited 2010-10-14 12:44
    I think Parallax forces the voltage on the SCL line but open drains the SDA line.

    I think that's a good idea because if something unexpected happens and some chip on the I2C bus tries to talk on the SDA line while the Prop is putting 3.3 VDC on it, it'll burn up...
  • KaosKiddKaosKidd Posts: 296
    edited 2010-10-14 12:49
    This is along the exact lines of what I have to do to read the HOST PC clock on the PS2 port in my PS2 Emulator.
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2010-10-14 13:57
    Makes sense, hadn't thought about in terms of trading master-slave designators on the buss'.
    Thanks-
  • jazzedjazzed Posts: 11,803
    edited 2010-10-14 22:07
    One of the nice things about using the output enable/disable approach is interfacing with 5V slave device parts. If the 5V part never drives the interface, the voltage levels should never exceed the voltage at the pull up resistor which is most likely 3.3V with Propeller. Still, there is always an exception somewhere.
Sign In or Register to comment.