PullUp/ PullDown Resistors

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

PullUp/ PullDown Resistors

Post by Derrihj »

Hi everyone hope u are OK, my question today is how do we enable internal pull-up resistors and pull-down resistors in a pic microcontroller like the PIC18F442 ?

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: PullUp/ PullDown Resistors

Post by Steve »

According to the datasheet for that device, only PORTB has an option for internal pull-ups. You have to add some C code in a C icon at the beginning of your program to enable them. Hopefully this will work:

Code: Select all

INTCON2bits.nRBPU = 0;

Derrihj
Posts: 348
Joined: Mon Jul 09, 2018 12:43 pm
Has thanked: 67 times
Been thanked: 33 times
Contact:

Re: PullUp/ PullDown Resistors

Post by Derrihj »

Thanks Steve, but 0 = PORTB pull-ups are enabled by individual port latch values. How do we write it if I want to enable pull_up resistor only for like port B2 ?

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: PullUp/ PullDown Resistors

Post by Steve »

I don't think you can as there is a single setting for all of PORTB. This is from the datasheet:
Each of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups. This is performed by clearing bit RBPU (INTCON2<7>). The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are disabled on a Power-on Reset.
If you need a pull-up (or pull-down) on an individual pin, then you'll have to chose a chip which has that functionality, or alternatively use an external resistor.

Post Reply