Programmable pull-up resistors.
Moderator: Benj
-
- Posts: 102
- Joined: Mon Aug 19, 2013 8:38 am
- Location: Netherlands
- Has thanked: 24 times
- Been thanked: 5 times
- Contact:
Programmable pull-up resistors.
In my search to minimize the number of part in my project I discovered on a circuitboard from my work there are no pull up/down resistors used in parallel of a dip switch at the Bport of a 16F722 . Looking in the datasheet I learned this port can be programmed for ‘weak pull up resistors’. My question is ,is this a option I can switch on in the full version or is it a flowcode instruction somehow?
- Attachments
-
- 1.JPG (33.29 KiB) Viewed 6021 times
-
- Knipsel2.JPG (48.95 KiB) Viewed 6021 times
-
- Knipsel3.JPG (97.82 KiB) Viewed 6021 times
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Programmable pull-up resistors.
It i not an option as far as I know, you will need to use a C icon to turn weak pull up on.
To turn weak pull up on for all pins:
Use wpub = 0b00000001 for B0 only, wpub = 0b00000010 for B1 only etc.
To turn weak pull up on for all pins:
Code: Select all
option_reg = option_reg & 0x7f;
wpub = 0b11111111;
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
-
- Posts: 102
- Joined: Mon Aug 19, 2013 8:38 am
- Location: Netherlands
- Has thanked: 24 times
- Been thanked: 5 times
- Contact:
Re: Programmable pull-up resistors.
Aha! so it's possible to put C code in a custom 'window'. I'll try to create that in advance. Thanks!
Means possible I need to reverse all my bcd codes if a dip switch is ON to ground.. ah well.. keeps me from the street
Means possible I need to reverse all my bcd codes if a dip switch is ON to ground.. ah well.. keeps me from the street
-
- Posts: 102
- Joined: Mon Aug 19, 2013 8:38 am
- Location: Netherlands
- Has thanked: 24 times
- Been thanked: 5 times
- Contact:
Re: Programmable pull-up resistors.
found in the 16F628A the same pull up resistor possibility! .HAd not looked before! THAT I can try here!
but the datasheet does not tell much ... or is this enough?
First the litlle text i could find from the 16F628 datasheet. what should I put in the c block here? looks like one command turns all on
Second... i already tried something for the 16f722 when I get to that. would the C block look like that?
but the datasheet does not tell much ... or is this enough?
First the litlle text i could find from the 16F628 datasheet. what should I put in the c block here? looks like one command turns all on
Second... i already tried something for the 16f722 when I get to that. would the C block look like that?
- Attachments
-
- Knipsel4.JPG (42.83 KiB) Viewed 6012 times
-
- Knipsel5.JPG (73.08 KiB) Viewed 6012 times
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Programmable pull-up resistors.
C block looks good for 16f722, you might want to remove the comment as it is not required. The 16f628 has only one bit to enable the pull-ups for all pins on port B.
For the 16f628 the C code would be:
For the 16f628 the C code would be:
Code: Select all
option_reg = option_reg & 0x7f;
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
-
- 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: Programmable pull-up resistors.
Hi Dutch,
Another way.
If you see in a data sheet to clear bit 7 of option_reg
Then you can use
Or if you know what register and bits are called:
E.g looking at page 25 of 722 data sheet and you want a weak pullup only on RB7 you have: Register is outlined in orange (You must use lower case)
Bit is outlined in red (You must use UPPER CASE)
then you can use:
clear_bit(wpub , WPUB7);
To set a bit you can use set_bit instead of clear_bit
If you need to set or clear more than on bit then you need to use masking just like in the format kersing posted.
If you need further help with bit masking just ask away.
Don't want to overwhelm with too much information
Martin
Another way.
If you see in a data sheet to clear bit 7 of option_reg
Then you can use
Code: Select all
clear_bit(option_reg , 7);
E.g looking at page 25 of 722 data sheet and you want a weak pullup only on RB7 you have: Register is outlined in orange (You must use lower case)
Bit is outlined in red (You must use UPPER CASE)
then you can use:
clear_bit(wpub , WPUB7);
To set a bit you can use set_bit instead of clear_bit
If you need to set or clear more than on bit then you need to use masking just like in the format kersing posted.
If you need further help with bit masking just ask away.
Don't want to overwhelm with too much information
Martin
Martin
-
- Posts: 102
- Joined: Mon Aug 19, 2013 8:38 am
- Location: Netherlands
- Has thanked: 24 times
- Been thanked: 5 times
- Contact:
Re: Programmable pull-up resistors.
Thanks Kersing ! have new food for thoughts now will try that asap (too bad it's not a pull down option )
Sure will look into that Martin. opens up possibility's.
Hmm data sheet can be overwhelming. but that's all you see for the first time!
Your help earlier on already helped great! dramatically simplified my flowcharts
sure have tons of Q in the future...
thanks for your support both!
Sure will look into that Martin. opens up possibility's.
Hmm data sheet can be overwhelming. but that's all you see for the first time!
Your help earlier on already helped great! dramatically simplified my flowcharts
sure have tons of Q in the future...
thanks for your support both!