CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Open drain configuration, or?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hmmpic



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

Open drain configuration, or?
PostPosted: Tue Oct 05, 2021 12:42 am     Reply with quote

Open drain configuration, or?

My PIC 18F27Q10 have Open Drain function.

I have powered the PIC 3,3V.
I interface one PIC pin to other chip. Other chip: IOL Max 0,3V IOH Max 1,2V. There are Pull UP in that chip to 1,2V.
Now i can use the port in normal way or special way Open Drain.

When using in normal way i can do this:
When PIC start pin are set to input, so ok because it is pull up to 1,2v.

Program code can be:
Code:

output_low(pin); (take pin low)

output_float(pin); //(pin is now a input, but it is PU to 1,2v inside the other chip so ok)

--So what is the difference if using the config as a Open Drain?
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Oct 05, 2021 12:59 am     Reply with quote

Standard PIC pin, can be setup as an input or an output. As an input, it
floats, so can be pulled up or down. As an output, two drive transistors, one
to pull it high and one to pull it low. Output_low turns the pull down one on.
However if you then used 'output_high', the pull up transistor would be
turned on. Now if this pin was being "wire or'ed" with other devices and
one of these was pulling it down, you would then have a conflict. So with the standard output, you can 'simulate' an open drain drive by only ever
driving low or letting it float. However the potential to drive the pin high is
still there.
If you accidentally used 'output_high', or the pin was being driven by a
peripheral (PWM, UART etc.), you have the potential for a conflict.

Now a genuine 'open drain' pin, disables the pull up transistor. So you could
then use 'output_low', and it'd drive low, but if you then use 'output_high',
the pull up transistor will not turn on, and the pin will be floating.
Using the open_drain configuration (only available on chips that support it,
and in many cases not of all ports), allows you to turn off the 'enable'
internally for the pull up transistor, making this conflict impossible.
Also means you can use the open drain ability on peripheral hardware.
So you can use a 'software' UART, and tell the code to only drive low,
but if you setup a hardware UART without the open_drain ability, the
pin will be driven both high and low. However setup the open_drain
ability on the hardware pin, and suddenly you can have an open_drain
UART output using the hardware.
hmmpic



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

PostPosted: Tue Oct 05, 2021 1:11 am     Reply with quote

Thanks nice explanation, thanks.

I just use what i normally do, using the output_float(pin);
Then my code can run in both PIC my 18F26K22 and my 18F27Q10...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group