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?
 


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


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
 
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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…