Pic 5.5 16F88 weak pull ups

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
SHORTCIRCUIT
Posts: 155
Joined: Thu Feb 10, 2011 4:39 am
Location: Las Vegas, Nevada USA
Has thanked: 40 times
Been thanked: 19 times
Contact:

Pic 5.5 16F88 weak pull ups

Post 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Post 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
Martin

SHORTCIRCUIT
Posts: 155
Joined: Thu Feb 10, 2011 4:39 am
Location: Las Vegas, Nevada USA
Has thanked: 40 times
Been thanked: 19 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Post 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Post 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
Martin

SHORTCIRCUIT
Posts: 155
Joined: Thu Feb 10, 2011 4:39 am
Location: Las Vegas, Nevada USA
Has thanked: 40 times
Been thanked: 19 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Post 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

zenzehar200
Flowcode v5 User
Posts: 11
Joined: Thu Apr 04, 2013 8:37 pm
Has thanked: 5 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Post by zenzehar200 »

Could some one tell me more about weak pull ups ??

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Post 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
Martin

SHORTCIRCUIT
Posts: 155
Joined: Thu Feb 10, 2011 4:39 am
Location: Las Vegas, Nevada USA
Has thanked: 40 times
Been thanked: 19 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Post 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Post 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
Martin

SHORTCIRCUIT
Posts: 155
Joined: Thu Feb 10, 2011 4:39 am
Location: Las Vegas, Nevada USA
Has thanked: 40 times
Been thanked: 19 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Post 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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Post by medelec35 »

Thanks Larry,
I really appreciate that.
So glad you're all sorted now.
Thanks for keeping us informed.

Martin
Martin

Post Reply