Weak pull-ups

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

echase
Posts: 426
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times
Contact:

Weak pull-ups

Postby echase » Sat Nov 26, 2011 7:29 pm

Am trying to implement weak pull-ups on 2 inputs of a 16F690 and am failing. Tried these as C Code block:-

option_reg.NOT_RABPU=0;
wpua.WPUA1=1;
wpua.WPUA2=1;

or
wpua.WPUA1=1;
wpua.WPUA2=1;
option_reg.NOT_RABPU=0;

or
option_reg.NOT_RABPU=0;
wpua=0x06;

The option_reg.NOT_RABPU=0; compiles correctly but all others give errors -somethnig wrong wth the C code it says. What am I doing wrong? Anything to do with some other lines on the A port being outputs instead of these 2 being inputs? I don’t switch any pin between in and out as it runs as they are always set to one or other. What is Flowcode doing behind the scenes e.g. in setting A/D inputs, although I use no Port A A/Ds. Anything to do with TRISA register?

I can enter it as ASM lines if it helps but no idea what the lines would be.

Rumour is that it defaults to pull up anyway so strictly I may not need the wpua.WPUA1=1 and wpua.WPUA2=1 lines.
Last edited by echase on Mon Nov 28, 2011 2:38 pm, edited 1 time in total.

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

Re: Weak pull-ups

Postby medelec35 » Sat Nov 26, 2011 8:05 pm

Hi echase,
echase wrote:Am trying to implement weak pull-ups on 2 outputs of a 16F690

Weak pull-ups are only available on the inputs and not o/p's. Or is that a typo?

Here is the easiest way to enable weak pullups on both port a and port b.
This is what I would use in a C code box:

Code: Select all

clear_bit(option_reg , 7);// Enable weak pull-ups
wpua = 0b00000101; //  WPU on RA2 and RA0
wpub = 0b10000000; //  WPU on RB7


Reason I would use binary is it's much easer to determine the correct value for the required port with out conversion :) .
E.g as you can see 00000101 = RA2 and RA0

Martin
These users thanked the author medelec35 for the post:
dannyvanneijenhoff (Fri Nov 28, 2014 12:09 pm)
Rating: 5.26%
 
Martin

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

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: Weak pull-ups

Postby Spanish_dude » Sat Nov 26, 2011 8:53 pm

I think the clear_bit function from v4 is clr_bit in v3.

If that doesn't work you can try this :

Code: Select all

option_reg = option_reg & ~(1 << 7);


Nicolas

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

Re: Weak pull-ups

Postby medelec35 » Sat Nov 26, 2011 9:04 pm

I was correct with what I have posted above, except it will not compile because of bugs in 16F690.TDF and PIC16F690.h files.
I have updated them, so if you back up your current 16F690.TDF (located in \Matrix Multimedia\Flowcode V3\boostc\config) and PIC16F690.h ( located in \Matrix Multimedia\Flowcode V3\boostc\include) files, then replace with ones attached on this post, the WPU on both A and B should then then work.

If Flowcode is running then best to exit and restart after replacing the two files.

I have tested with:

Code: Select all

clear_bit(option_reg , 7);// Enable weak pull-ups
wpua = 0b00000101; //  WPU on RA2 and RA0
wpub = 0b10000000; //  WPU on RB7


It successfully compiled to hex with both of my FC3 and FC4
Note: None of the two files have not been approved by Matrix Multimedia

Martin
Attachments
Updated files.zip
(6.07 KiB) Downloaded 170 times
These users thanked the author medelec35 for the post (total 2):
Benj (Mon Nov 28, 2011 10:56 am) • echase (Mon Nov 28, 2011 2:44 pm)
Rating: 10.53%
 
Martin

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

echase
Posts: 426
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times
Contact:

Re: Weak pull-ups

Postby echase » Mon Nov 28, 2011 2:33 pm

Thanks, I meant inputs, edited original.

Will

option_reg.NOT_RABPU=0;
wpua.WPUA1=1;
wpua.WPUA2=1;

work with your revised 690 files?

You mentioned that your lines work on port A and B. Do I need to specifically include a command like wpub = 0b00000000; to turn them off on Port B as it might cause circuit problems with them all on.

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

Re: Weak pull-ups

Postby medelec35 » Mon Nov 28, 2011 3:46 pm

echase wrote:Will

option_reg.NOT_RABPU=0;
wpua.WPUA1=1;
wpua.WPUA2=1;

work with your revised 690 files?

Not sure, I would be able to test until later today.
echase wrote:You mentioned that your lines work on port A and B. Do I need to specifically include a command like wpub = 0b00000000; to turn them off on Port B as it might cause circuit problems with them all on

I’m afraid when you enable weak pull-ups, the default is on. Since the function is enable all pull-ups
So if you want none of portb enabled then you can just do:

Code: Select all

 wpub = 0b00000000;

Or

Code: Select all

wpub = 0x0;

However the weak pull-up is only active if the pins are set to i/p.
If pin is an o/p then weak pull-up on that pin will be disabled.

Martin
Martin

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

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

Re: Weak pull-ups

Postby medelec35 » Mon Nov 28, 2011 4:50 pm

Update:
Just tried:

Code: Select all

option_reg.NOT_RABPU=0;
wpua.WPUA1=1;
wpua.WPUA2=1;
With the two amended files.
Compiles OK and is working.

But you need to use 0 to turn WPU pins off. Otherwise wpua.WPUA1=1; will not change anything since its value is already 1 (all the WPU pins are set as 1 as stated in previous post)

Does not work without the files replaced.

Martin
Martin

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

echase
Posts: 426
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times
Contact:

Re: Weak pull-ups

Postby echase » Mon Nov 28, 2011 11:25 pm

Seems to work, thanks.

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

Re: Weak pull-ups

Postby medelec35 » Tue Nov 29, 2011 12:20 am

Your welcome.

Glad WPU is working for you.

Thanks for letting us know.

Martin
Martin

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