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

PORTB : pullups and using input_b()

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



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PORTB : pullups and using input_b()
PostPosted: Fri Feb 09, 2007 8:54 pm     Reply with quote

Hello, this is really newbie question. Lower 4 bits of portB are outputs, higher are inputs.
Therefore I set set_tris_b(0xF0);
To the upper 4 bits buttons are connected. If there is an internal pullup it means that I can use a button without my own pullup resistor?
I suppose that these pullups can be set just for the 4 bits of the portB.
Another issue is that if I read a value of the portB (byte value = input_b();), all 4 outputs of the port goes to low. How can I aware changing states of outputs?
thanks in advance,
M.
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Fri Feb 09, 2007 9:17 pm     Reply with quote

With most PICs you can't set pullups for individual pins or groups of pins. It's all or nothing. That said, the pullups only affect the pins that are set to be inputs. Your four buttons should be connected from the PIC pins to ground. Pushing the button should close the switch and short the PIC pin to ground.

The reason that an input_b() read of the port screws up the 4 output pins is because of the default standard_io in use. The compiler assumes that you want it to automatically take care of setting the port direction based on what you do in the code. An output_b() command would cause it to set the port to an output, and input_b() causes it to set the entire port to input.

The way you tell the compiler to let you take care of everything is through one of the #use io commands. The default, as I mentioned is #use standard_io(B). You want #use fast_io(B). Consult the compiler help and/or the manual for more information.
meereck



Joined: 09 Nov 2006
Posts: 173

View user's profile Send private message

PostPosted: Sat Feb 10, 2007 11:58 am     Reply with quote

thank you
Regards
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