When bit-banging I2C using 2 PIO lines do these lines still need to be pulled high? Obviously using a dedicated I2C bus the lines must be pulled high as the pins are open-drain outputs but PIO pins aren't open-drain.


1 Answer 1


Yes, both lines need to be pulled high at all time.

Also, when bitbanging I2C, rather than switching the LOW/HIGH states of the pin, switch between LOW/HiZ by simply altering the DDR/DIR registers.

  • \$\begingroup\$ The data pin needs to be pulled high, but not necessarily the clock. \$\endgroup\$ Commented Mar 19, 2014 at 10:19
  • \$\begingroup\$ Why is that? Well, I guess, if you only have one master, don't account for slave-induced clock stretching, etc. \$\endgroup\$
    – Dzarda
    Commented Mar 19, 2014 at 10:24
  • \$\begingroup\$ Why switching between LOW/HiZ is rather than switching between LOW/HIGH states of the pin? \$\endgroup\$ Commented Jun 7, 2015 at 3:56
  • \$\begingroup\$ As this isn't an answer, it should probably be posed as its own question, or a comment on Dzarda's answer. But anyway, High-Z is used because I2C is a multi-device bus and is designed so that devices are only allowed to drive low, and then an external resistor pulls the line high - this means if one device is trying to output a 1 while another is driving a 0, then they don't short each other out - because the device trying to output a 1 is in High-Z and a resistor is pulling up for it. \$\endgroup\$ Commented Jun 7, 2015 at 4:07
  • \$\begingroup\$ @TomCarpenter: For the case of a single master driving SPI devices that do not use clock stretching, using an actively driven clock is fine, provided that the time required for the passive pull-up on SDA to generate a rising edge is shorter than the minimum delay between releasing SDA and driving SCK high. \$\endgroup\$
    – supercat
    Commented May 25, 2016 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.