Pic 5.5 16F88 weak pull ups
Moderator: Benj
-
- Posts: 155
- Joined: Thu Feb 10, 2011 4:39 am
- Location: Las Vegas, Nevada USA
- Has thanked: 40 times
- Been thanked: 19 times
Pic 5.5 16F88 weak pull ups
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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Pic 5.5 16F88 weak pull ups
Hi SHORTCIRCUIT,
Looking at page 18 of the data sheet it shows that: 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
at the start of main.
Martin
Looking at page 18 of the data sheet it shows that: 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);
Martin
Martin
-
- Posts: 155
- Joined: Thu Feb 10, 2011 4:39 am
- Location: Las Vegas, Nevada USA
- Has thanked: 40 times
- Been thanked: 19 times
Re: Pic 5.5 16F88 weak pull ups
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.
Larry
How do I set individual bits for weak pull ups?
I need to set bits 7,6,4,1 (11010010)
Thank you again.

Larry
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Pic 5.5 16F88 weak pull ups
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
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
-
- Posts: 155
- Joined: Thu Feb 10, 2011 4:39 am
- Location: Las Vegas, Nevada USA
- Has thanked: 40 times
- Been thanked: 19 times
Re: Pic 5.5 16F88 weak pull ups
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
Now, I have to experiment to reinforce what you have just said.
I wish I understood C better.
Larry
-
- Flowcode v5 User
- Posts: 11
- Joined: Thu Apr 04, 2013 8:37 pm
- Has thanked: 5 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Pic 5.5 16F88 weak pull ups
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
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
-
- Posts: 155
- Joined: Thu Feb 10, 2011 4:39 am
- Location: Las Vegas, Nevada USA
- Has thanked: 40 times
- Been thanked: 19 times
Re: Pic 5.5 16F88 weak pull ups
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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Pic 5.5 16F88 weak pull ups
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
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
-
- Posts: 155
- Joined: Thu Feb 10, 2011 4:39 am
- Location: Las Vegas, Nevada USA
- Has thanked: 40 times
- Been thanked: 19 times
Re: Pic 5.5 16F88 weak pull ups
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
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Pic 5.5 16F88 weak pull ups
Thanks Larry,
I really appreciate that.
So glad you're all sorted now.
Thanks for keeping us informed.
Martin
I really appreciate that.
So glad you're all sorted now.
Thanks for keeping us informed.
Martin
Martin