16F886 & 18F2620 Pull Up resistor Configuration
16F886 & 18F2620 Pull Up resistor Configuration
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
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
- 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
This is from the 16F886 datasheet:
And this is from the 18F2620 datasheet:
So the answer is "yes" for this chip. In C code: wpub = 0xC0;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.
And this is from the 18F2620 datasheet:
So the answer for this chip is no.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.
Re: 16F886 & 18F2620 Pull Up resistor Configuration
Hello,
How does
In C code: wpub = 0xC0;
relate (0xC0) to the Pins RB6 & RB7?
Thanks
Ron
How does
In C code: wpub = 0xC0;
relate (0xC0) to the Pins RB6 & RB7?
Thanks
Ron
- 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
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).
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).
Re: 16F886 & 18F2620 Pull Up resistor Configuration
Would you consider 16F886 & 18F2620 equivalent to each other? I am looking for a pin compatible to the 886 with about twice the ROM.
Re: 16F886 & 18F2620 Pull Up resistor Configuration
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.
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.
Re: 16F886 & 18F2620 Pull Up resistor Configuration
So it is
wpub = 0x00;
To turn off all the pullups?
wpub = 0x00;
To turn off all the pullups?
Re: 16F886 & 18F2620 Pull Up resistor Configuration
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?
Re: 16F886 & 18F2620 Pull Up resistor Configuration
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.
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.
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: 16F886 & 18F2620 Pull Up resistor Configuration
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.