16F886 & 18F2620 Pull Up resistor Configuration

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

Moderators: Benj, Mods

Post Reply
Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

16F886 & 18F2620 Pull Up resistor Configuration

Post by Ron »

Hi,

Can the built in pull up resistors be configured independently of each other (not the entire port)?


If they can, how would I do it for

16F886 RB6 & RB7?

18F2620 RB6 & RB7?


Thanks

Ron

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

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by Steve »

This is from the 16F886 datasheet:
3.4.2 WEAK PULL-UPS
Each of the PORTB pins has an individually configurable
internal weak pull-up. Control bits WPUB<7:0> enable or
disable each pull-up (see Register 3-7). Each weak
pull-up is automatically turned off when the port pin is
configured as an output. All pull-ups are disabled on a
Power-on Reset by the RBPU bit of the OPTION register.
So the answer is "yes" for this chip. In C code: wpub = 0xC0;

And this is from the 18F2620 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.
So the answer for this chip is no.

Ron
Posts: 225
Joined: Wed Apr 11, 2007 6:15 pm
Has thanked: 2 times

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by Ron »

Hello,

How does

In C code: wpub = 0xC0;

relate (0xC0) to the Pins RB6 & RB7?

Thanks

Ron

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

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by Steve »

Have a look at the datasheet for the 16F886 (the section on portb). Each bit of WPUB represents the individual pullup state of each bit of portb. A "1" means the pullup is enabled and a "0" means the pullup is disabled.

0xC0 (hex) = 11000000 (binary), so the WPUB settings for B6 and B7 are "1" (enabled) and for the rest of the port they are "0" (disabled).

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by echase »

Would you consider 16F886 & 18F2620 equivalent to each other? I am looking for a pin compatible to the 886 with about twice the ROM.

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

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by Steve »

I don't know that device very well, but I had a quick look at the datasheet and it looks like a good bet.

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by echase »

By default does Flowcode put the pull-ups on or off?

The problem with a default of on is that if you put a switch from the port to 5V and a pull down resistor of 100K then the weak pull-up is stronger than the 100k and so there is a permanent high on the input and the switch does nothing. I have been struggling to get my switches working on Port B of a 16F886 and I think it may be something to do with this weak pull-up being on all the time. Until I read this post I was not aware that it had internal pull-ups.

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by echase »

So it is

wpub = 0x00;

To turn off all the pullups?

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

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by Steve »

That's correct.

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by echase »

If I cut my code down to almost nothing apart from wpub=0x00; then the pull-ups turn off. But as soon as I add lines to get the code to anything real like write to LCD on Port B or read a value from Port B the pull-ups turn on again and I can’t get them to go off again, even if I add a wpub=0x00 line after every port read or write. How do I get the pull-ups permanently disabled?

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

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by Steve »

That seems strange. Is there any external hardware that is causing the pull-ups?

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by echase »

Looks to me that my LCD also has weak pull-ups in it as when LCD disconnected the PIC is fine and reacts to the wpub = 0x00;

The confusing thing is that when measured with an ohmmeter when power off the LCD inputs show infinite resistance, but these weak pull-ups must get activated when power is connected.

Only way around this is to reduce my pull-down resistor values a lot so it defeats these weak pull-ups.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by Benj »

Hello

You could always reverse the operation of your switches. Eg so they yield a logic 0 by ppulling to ground when pressed. This would mean that the pull ups would work in your favour instead of against it.

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Re: 16F886 & 18F2620 Pull Up resistor Configuration

Post by echase »

Good idea but not sure my brain can cope with remembering that on is off and off is on when I am programming! I tried it once before and got rapidly lost.

Post Reply