Electronics > Beginners
How to define a microcontroller pin as open collector or open drain??
(1/3) > >>
khatus:


https://www.microcontrollertips.com/what-is-an-open-drain-faq/

I have understood the fundamental theory of open collector and open drain configuration. But the problem is How to define/make a micro controller's pin as open drain??Does any pin of a micro controller can be used in open drain configuration??

2. If i define a GPIO pin as an input pin, Can I use this pin in open drain configuration?
3. Does it mandatory to define a pin as output for using it in open drain configuration??



Benta:
It is extremely rare that microcontrollers have open-drain output pins, they're almost always complementary.
If you need open-drain functionality, you'll extra hardware, eg, a MOSFET transistor.
mikeselectricstuff:
Some MCUs have explicit OD modes, but any bidirectional pin can be used as open drain by setting it as low output for on, and input as off.
However note you can't externally pull it to higher than Vcc due to input protection diodes.
khatus:
 I2C communication require two pull up resistor for SDA and SCL.
 Are SDA and SCL  open-drain output pins???
jimmc:
mikeselectricstuff has just beaten me to to it, but as he says you can emulate an open drain output by switching between output and input as required.
Below are my comments from an Arduino based GPIB program. Here I wanted an 'open drain' with a weak pull up.

// Asserted   (Low state)   digitalWrite(xx, LOW); pinMode(xx, OUTPUT), This way round to ensure output never 'glitches' to +5v
// Unasserted (High state)  pinMode(xxx, INPUT_PULLUP), High by internal pullup only (20-50 kOhm)

Again as Mike said, beware the protection diodes to Vdd.

Jim
Navigation
Message Index
Next page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod