Weak pull-ups

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

Moderators: Benj, Mods

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

Weak pull-ups

Post by echase »

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.

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: Weak pull-ups

Post by medelec35 »

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
Martin

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

Post by Spanish_dude »

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

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: Weak pull-ups

Post by medelec35 »

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 343 times
Martin

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

Re: Weak pull-ups

Post by echase »

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.

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: Weak pull-ups

Post by medelec35 »

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

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: Weak pull-ups

Post by medelec35 »

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

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

Re: Weak pull-ups

Post by echase »

Seems to work, thanks.

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: Weak pull-ups

Post by medelec35 »

Your welcome.

Glad WPU is working for you.

Thanks for letting us know.

Martin
Martin

Post Reply