CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

internal pull-ups 26k20

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
overmindx



Joined: 06 Oct 2008
Posts: 43

View user's profile Send private message

internal pull-ups 26k20
PostPosted: Tue Jan 11, 2011 3:34 am     Reply with quote

hi in the datasheet of an 18f26k20, it says:

Quote:

10.3.1 WEAK PULL-UPS
Each of the PORTB pins has an individually controlled
weak internal pull-up. When set, each bit of the WPUB
register enables the corresponding pin pull-up. When
cleared, the RBPU bit of the INTCON2 register enables
pull-ups on all pins which also have their corresponding
WPUB bit set. When set, the RBPU bit disables all
weak pull-ups.


in my understanding (correct me if im wrong) but it seems, it indicates that you could manually enable pull-ups for each pin.. am i correct? if yes, how can i do this? i tried to set the individual bits of WPUB but it doesnt work.. i dont want to use PORT_B_PULLUPS since it will enable all pull-ups in PORTB.. please help.. thanks in advance
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Tue Jan 11, 2011 5:24 am     Reply with quote

Port_b_pullups.....

Read the manual about this. It has _two_ modes of operation, depending on the chip involved. On chips that only have pullups on _all_ pins, it simply enables them all. However on chips that allow individual bits to be turned on separately, it can be used like:

port_b_pullups(0b10101010);

and will then just enable the pullups on B1,B3 etc..

So it doesn't "enable all pull-ups in PORTB". If the chip supports enabling them individually, so does the function.

Best Wishes
overmindx



Joined: 06 Oct 2008
Posts: 43

View user's profile Send private message

PostPosted: Tue Jan 11, 2011 7:29 am     Reply with quote

it seems when i tested it, using port_b_pullups enables all pull-ups. its because when i used port_b_pullups(0b11101111), it still enables the pull-up on pin_B4. is there a way to enable the pullup on a specific pin using 18f26k20? if there is, please help.. thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Tue Jan 11, 2011 8:29 am     Reply with quote

Obvious question. What compiler version?.
Have just tested with 4.114, and it correctly disables the pull up on B4, with port_b_pullups(0b11101111);

I'd not put is past a significantly older version to get the control 'wrong', since unlike most chips, on this one, you have to disable the 'port b pullups' enable bit, to use the individual bits. 4.114, does this correctly. 4.099, handles the control wrongly, enabling all the pullups, so it is something that has been fixed between these versions

Best Wishes
overmindx



Joined: 06 Oct 2008
Posts: 43

View user's profile Send private message

PostPosted: Tue Jan 11, 2011 9:00 pm     Reply with quote

too bad.. i am using v.4.096...
Sad


thanks for reply..
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Wed Jan 12, 2011 3:21 am     Reply with quote

OK. In which case you will have to go 'manual'.
As you surmised, you need to enable the bits manually in WBPU, but you also need to _clear_ the pull up enable bit, which otherwise overrides these. So something like:
Code:

#byte INTCON2 = getenv("SFR:INTCON2")
#byte WPUB = getenv("SFR:WPUB")
#bit RBPU = INTCON2.7

void my_port_b_pullups(int8 mask) {
    RBPU=0;
    WPUB=mask;
}


Then use just like 'port_b_pullups', so in the future if you upgrade to a compiler that works, you can just switch to the supplied function.

Best Wishes
overmindx



Joined: 06 Oct 2008
Posts: 43

View user's profile Send private message

PostPosted: Thu Jan 13, 2011 3:28 am     Reply with quote

THANKS!! Smile
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group