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

pull up vs pull down resistors

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



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

pull up vs pull down resistors
PostPosted: Wed Oct 24, 2007 12:20 am     Reply with quote

Hi there, been browsing through forum and saw a query about pull up resistors, and was wondering if it would be possible to connect the pins to ground through a resistor and then let the switch connect the pin to Vcc eg pull down.

This way your logic would be the right way around. Switch on = 1 switch off = 0. I'm busy with a project using a lot of DIP switches so i don't want to invert things the whole time.

Would this setup work or will too much current flow into the pin?? Or am i missing something else here??
Ttelmah
Guest







PostPosted: Wed Oct 24, 2007 2:08 am     Reply with quote

No reason at all.
The reasons "pull up's", are more common, comes from a multitude of things. It allows one side of the switch to be grounded (potential safety improvement), it is also what the default internal "bias resistors" on port-B offer. These followed common practice dating back to older logic families, which often had some degree of internal pull-up. There is nothing to stop you using pull down resistors if this is what you want.
However there is really no 'inversion' involved in working the other way. Two comments apply:.
1) Some systems will have switches designed to 'fail safe', so an 'open' switch is the 'off' condition, so if a wire fails 'off' is always seen.
2) The processor itself, is just as happy testing for a '1' as a '0', so you can (for example), write like:
Code:

#define ON (0)
#define OFF (1)
#bit SWITCH1=PORTA.0 //whatever suits your switch

if (SWITCH1==ON)

Which means you never have to worry about which 'way' the switch operates.

Best Wishes
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Oct 24, 2007 8:52 am     Reply with quote

One reason pull-up resistors are more common is due to having open-collector outputs that allow things to be 'disconnected' from the rest of the circuit. These outputs pull the pin to ground via a transistor and when turned of the output simply 'floats' with no voltage level being forced. The only way to have this pin go high is to have some device, another output from a different chip or a pull-up resistor, pull it up. This comes in handy when you need to allow a different part take control of that particular signal pin.

Ronald
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

Inverting port data
PostPosted: Wed Oct 24, 2007 9:52 am     Reply with quote

Hi guys, thanks for the replies.

The reason i want to use pull-down is that the dip switches are to be used as the address for an EEPROM memory, so the whole port is being read. so i want things to work as you see them, no reverse/inverse operation. i havn't done any reading yet on inversing the results if i use pull-ups, any ideas or suggestions??
Ttelmah
Guest







PostPosted: Wed Oct 24, 2007 9:55 am     Reply with quote

Not exactly hard.

val = ~input;

will invert all the bits.

Best Wishes
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

invert bits
PostPosted: Wed Oct 24, 2007 10:05 am     Reply with quote

Gee that was easy!!! Very Happy I wil go and simplify my PCB design now, will save a lot of tracks.....

Thanks Ttelmah, shows you i should read the manual more... Embarassed

Keep well
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