As far as I have read, the I2C pins are Open Drain or Open collector, but in the PIC18F2550 the datasheet doesnt say anything about those pins, and even says they are a digital output if you select them to be one.
Do I need to add a pullup resistor to the pins so to use them as a digitial output?
If I dont, how do they work in the I2C?
Thanks!
Electronic – PIC18F2550 I2C Open Drain
i2copen-collectoropen-drainpic
Best Answer
You can do open drain on any digital pin on the PIC yourself, it's easy! I'll show through a quick chunk of example code using RB0.
The I2C module will do something similar to this internally, without you doing anything. In other words: yes! You'll need a pullup resistor!
EDIT: To answer your second question which I did not directly address, the pin does not need a pullup resistor during normal digital output operation. My example was to show you how a normal, fully functioning digital I/O pin could operate as a open-drain without any additional behavior or behaving unexpectedly. I should also note that I have done this exactly what I showed here to do open-drain in real programs, so this isn't a toy example, it's really how you do it!