PullUp/ PullDown Resistors
Moderator: Benj
-
- Posts: 348
- Joined: Mon Jul 09, 2018 12:43 pm
- Has thanked: 67 times
- Been thanked: 33 times
- Contact:
PullUp/ PullDown Resistors
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 ?
- Steve
- Matrix Staff
- Posts: 3421
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
- Contact:
Re: PullUp/ PullDown Resistors
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;
-
- Posts: 348
- Joined: Mon Jul 09, 2018 12:43 pm
- Has thanked: 67 times
- Been thanked: 33 times
- Contact:
Re: PullUp/ PullDown Resistors
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 ?
- Steve
- Matrix Staff
- Posts: 3421
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
- Contact:
Re: PullUp/ PullDown Resistors
I don't think you can as there is a single setting for all of PORTB. This is from the datasheet:
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.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.