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

SHORTCIRCUIT
Posts: 152
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

Postby SHORTCIRCUIT » Mon Apr 01, 2013 12:20 pm

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3451 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Postby medelec35 » Mon Apr 01, 2013 12:54 pm

Hi SHORTCIRCUIT,

Looking at page 18 of the data sheet it shows that:
Weakpullups.png
Weakpullups.png (73.31 KiB) Viewed 3238 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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

SHORTCIRCUIT
Posts: 152
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

Postby SHORTCIRCUIT » Mon Apr 01, 2013 1:12 pm

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3451 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Postby medelec35 » Mon Apr 01, 2013 1:34 pm

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
These users thanked the author medelec35 for the post:
SHORTCIRCUIT (Fri May 18, 2018 9:06 pm)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

SHORTCIRCUIT
Posts: 152
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

Postby SHORTCIRCUIT » Mon Apr 01, 2013 1:39 pm

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

Postby zenzehar200 » Tue Apr 09, 2013 9:36 pm

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3451 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Postby medelec35 » Tue Apr 09, 2013 10:47 pm

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
These users thanked the author medelec35 for the post:
electrolaw (Tue Apr 16, 2013 5:10 pm)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

SHORTCIRCUIT
Posts: 152
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

Postby SHORTCIRCUIT » Fri May 18, 2018 7:07 pm

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3451 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Postby medelec35 » Fri May 18, 2018 7:17 pm

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
These users thanked the author medelec35 for the post:
SHORTCIRCUIT (Fri May 18, 2018 8:40 pm)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

SHORTCIRCUIT
Posts: 152
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

Postby SHORTCIRCUIT » Fri May 18, 2018 8:39 pm

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
These users thanked the author SHORTCIRCUIT for the post:
medelec35 (Fri May 18, 2018 11:08 pm)
Rating: 5.26%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8440
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2412 times
Been thanked: 3451 times
Contact:

Re: Pic 5.5 16F88 weak pull ups

Postby medelec35 » Sat May 19, 2018 9:04 pm

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

Martin
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.