Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Open Drain Pins and Level Converters

Status
Not open for further replies.

gaspode42

Member
Good Morning All,

I am just working on a project using a 16F887 and MAX232 etc. One of the IC's I am using has an output of only 3v so I was going to include a level converter before I/O to the pic. However one if the pins that requires conversion states that it needs to be connected to an Open Drain Pin on the processor - having looked at the data-sheet (very quickly I may add) I can not find one on the 16F887 and how do I do the level shift? Just got my brain in a bit of a knot - so any advice would be much appreciated.
 
Another Idea

If I provide my circuit it a 3V LDO regulator to power the 3V device and I then use the comparator in the 16F887 to determine low/high? If this is a workaround then how can I 'simulate' and open drain I/O as the 3V device has an internal pull-up which must be pulled to ground as part of the configuration - can I take a pic output to feed the gate of a mosfet and take the pin to ground via that?
 
If I provide my circuit it a 3V LDO regulator to power the 3V device and I then use the comparator in the 16F887 to determine low/high? If this is a workaround then how can I 'simulate' and open drain I/O as the 3V device has an internal pull-up which must be pulled to ground as part of the configuration - can I take a pic output to feed the gate of a mosfet and take the pin to ground via that?


Is this for an I2C interface?

Write a '0' to the PICs I/O port register to take the I/O port pin low. Then set the TRIS bit for that port bit to either input or output.

When it's set as an output the pin is driven low, when it's set as an input it looks like an open drain.
 
No this is not an I2C configuration. It's for a custom ASIC. Each time you clock the chip it will return one bit of data. That is why I was thinking of using the comparator as speed is not an issue as such, I can clock the chip and wait for the comparator result as the next bit. However as part of the ASIC configuration

DATA is normally an output to the ASIC held high in its default state, but the pin is designed with a one-
shot strong pull-up in combination with a constant weak current-source drive such that a micro-controller
may reliably overpower or force it low as part of initiating a reset. Note that the micro-controller unit
(MCU) or other device pin connected to the ASIC’s DATA pin must be a low-leakage input, such as
found in typical CMOS devices. Furthermore the user’s pin must have the capability of driving the pin
low. If minimizing current consumption while forcing DATA low is desired, the MCU pin should not
include a pull-up. A common configuration conveniently meeting these constraints is the open-drain
“Port 0” I/O pin from the popular “8051” series of MCUs.

Is this going to be a problem or will any pin (using the above configuration be OK? Is the comparator a workable solution or will the PIC reliably read a 3V signal as '1' on an input?
Thanks to all who have replied so far, especially geko who has answered a number of my questions over the last two days - all your replies are much appreciated :D
 
Bill

Just choose an input pin that's not a Schmitt trigger.

Thanks for that - do I then change the TRIS as suggested by Geko? What do you think of the comparator idea or have I completely misunderstood you ?
 
Bill

Thanks again - I will check the 16F887 data-sheet and see what I can find. Will come back to you if I can't find anything !!
 
Use a normal I/O pin, non-schmitt like Bill said, and the code like this to either drive the i/o pin low, or let the ASIC drive/pull it up by setting it to an input.


Code:
       ; drive i/o port bit n low
       bcf            PORTX, bitn
       banksel        TRISX
       bcf            TRISX, bitn
       banksel        PORTX
 
       ; make i/o port bit n like open drain
       banksel        TRISX
       bsf            TRISX, bitn
       banksel        PORTX


Make sure to always set the PORT bit low before setting it to an output as read-modify-writes to the port elsewhere in the code may cause it to get set high when the port is read and the pin is an input.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top