Page 1 of 1

Pic 5.5 16F88 weak pull ups

Posted: Mon Apr 01, 2013 12:20 pm
by SHORTCIRCUIT
I'm sorry to say that my C programming ability does not exist.

Will someone please tell me how to turn on all weak pull ups on a 16F88..
I have never been able to use the C programming feature with any success.
Larry

Re: Pic 5.5 16F88 weak pull ups

Posted: Mon Apr 01, 2013 12:54 pm
by medelec35
Hi SHORTCIRCUIT,

Looking at page 18 of the data sheet it shows that:
Weakpullups.png
(73.3 KiB) Downloaded 4556 times
If you clear bit 7 (RPBU with a bar means NOT RPBU = reset to 0 to enalbe weak pull-ups) of OPTION REG then PORTB pull-ups are enabled by individual port latch values.

Since Registers are in lower case then just use a Cblock with

Code: Select all

clear_bit(option_reg , 7);
at the start of main.

Martin

Re: Pic 5.5 16F88 weak pull ups

Posted: Mon Apr 01, 2013 1:12 pm
by SHORTCIRCUIT
Martin, thank you so much. Please take me to another level.
How do I set individual bits for weak pull ups?
I need to set bits 7,6,4,1 (11010010)

Thank you again. :D
Larry

Re: Pic 5.5 16F88 weak pull ups

Posted: Mon Apr 01, 2013 1:34 pm
by medelec35
Hi Larry,
Since all the port B will have weak pull-ups enabled, Do don't need to do anything to enable individual weak pull-ups.

Reason being: default for all ports on reset are inputs.

When configured and when any portB pin is set as an output the weak pull-up for that pin is disabled.
When using an i/p on a pin that has a WPU enabled, the i/p resistance should have a lower resistance then of the weak pull-ups (hence the term weak)

If you need a portB pin as a i/p but want the WPU disabled, then set as o/p then back to i/p e.g using an i/p component icon or ADC component etc.

Martin

Re: Pic 5.5 16F88 weak pull ups

Posted: Mon Apr 01, 2013 1:39 pm
by SHORTCIRCUIT
Martin, thank you very much, I think I understand.
Now, I have to experiment to reinforce what you have just said.

I wish I understood C better.

Larry

Re: Pic 5.5 16F88 weak pull ups

Posted: Tue Apr 09, 2013 9:36 pm
by zenzehar200
Could some one tell me more about weak pull ups ??

Re: Pic 5.5 16F88 weak pull ups

Posted: Tue Apr 09, 2013 10:47 pm
by medelec35
A weak pull-up is just an internal pull-up built into microcontroller that pulls the input high towards +5V.
This is so the i/p is not floating if you connect a switch between i/p and ground, and switch is open circuit.

It saves on hardware since you will use internal weak pull-ups instead of external resistors.

Looking at 16F88 datasheet for an example.
On page 173 it shows the typical current though weak pull-up is 250 uA
Therefore the equivalent resistance is about 5/250x10E-6 = 20K

If you change i.p to an output then the weak pull-up for that pin is automatically disabled.

Martin

Re: Pic 5.5 16F88 weak pull ups

Posted: Fri May 18, 2018 7:07 pm
by SHORTCIRCUIT
I hate to resurrect such an old thread. But I am having same problem.
The last I was on this thread I was using Flowcode 5, I think!

I am using Flowcode 7 and having trouble with:
//Enable port B weak pull-ups
clear_bit(option_reg , 7);

When I compile to Hex I get the following errors:
2141: option_reg &= ~(1 << 7);
^ (192) undefined identifier "option_reg"

Am I doing something wrong in Flowcode 7 or is this a
meaningless unexpected normal response.

Will I get pull ups enabled or do I need to do something different?
This command line worked fine in V5. Has something change like OSCCON = osccon.

Look forward to the reply!
Larry

Re: Pic 5.5 16F88 weak pull ups

Posted: Fri May 18, 2018 7:17 pm
by medelec35
Hi Larry,
The reason for the error is now flowcode is using a different compiler (Microchip) to pre V7 (BoostC)
Take a look here.
If after reading you are still a bit stuck then I'm happy to help you further.

Martin

Re: Pic 5.5 16F88 weak pull ups

Posted: Fri May 18, 2018 8:39 pm
by SHORTCIRCUIT
Hi Martin
Thank you for the reply.
I tried both of the C examples and still got failures.

When I applied:
clear_bit(OPTION_REG,nWPUEN);
Still got an error, then I got smart and stopped being lazy, so I opened the 16F88 spec-sheet and realized that
I need to replace nWPUEN with nRBPU and it complied correctly.

The final c code line looked like this for the 16F88:
clear_bit(OPTION_REG,nRBPU);

Martin, thank so much for your help. I would have never figured that out on my own.
As always, you are awesome!
Larry

Re: Pic 5.5 16F88 weak pull ups

Posted: Sat May 19, 2018 9:04 pm
by medelec35
Thanks Larry,
I really appreciate that.
So glad you're all sorted now.
Thanks for keeping us informed.

Martin