Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
The data pin needs to be pulled high, but not necessarily the clock. –  Erik Friesen Mar 19 '14 at 10:19
    
Why is that? Well, I guess, if you only have one master, don't account for slave-induced clock stretching, etc. –  Dzarda Mar 19 '14 at 10:24
    
Why switching between LOW/HiZ is rather than switching between LOW/HIGH states of the pin? –  Akshara Prasad Jun 7 at 3:56
    
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. –  Tom Carpenter Jun 7 at 4:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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