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

How I use the input with pull up/down internal resistor?

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



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

How I use the input with pull up/down internal resistor?
PostPosted: Sat Jul 02, 2011 4:08 am     Reply with quote

How to build an application using the input with the pull up/down internal resistor from the microcontroller or microchip.
Can I use that and analog inputs?
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sat Jul 02, 2011 5:00 am     Reply with quote

'Resistors' are generally pull-up only, not pull up/down.
They are actually programmable current sources, rather than resistors, so for an analog application might give rather different results than a resistor. Also currents involved vary significantly from pin to pin. The data sheets are generally very unclear whether these can be enabled on a pin configured as analog. But does in most cases say these are for digital inputs only. A search finds the 16F688, with a block diagram for the pin logic, (Figure 4-1), which clearly shows that the pull up is _disabled_ when the port is set to analog, for either comparator, or ADC.
So I'd say you cannot use the pull-ups with pins set for analog.

Remember also the impedance requirements for analog inputs. The leakage current on an input pin would be over 1/10th the available current on these weak pull-ups, so any form of accuracy would be lost....

Best Wishes
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Sat Jul 02, 2011 9:36 am     Reply with quote

Thanks Ttelmah
So no each controller has a system pull up resistance.
I worked with PIC12F509 and pull up resistor is activated automatically if you read input pin B0, B1, B3, B4 for B2, B5 don't have.
If the algorithm operates with pull up separately for 16F688 do you know an example?

For Atmel have pull up resistor and of course pull down.
Atmega16 is a example.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Sat Jul 02, 2011 3:12 pm     Reply with quote

You really have to read the data sheet for the chip you are using. There are digital inputs, analog inputs, and Schmitt trigger inputs. Common outputs are digital, PWM, and open collector or open drain, and any output may or may not have a pull up resistor or current source as well.

The are far too many types to cover them all in a BBS posting.

Read your data sheet and get back with specific questions about specific chips.
_________________
The search for better is endless. Instead simply find very good and get the job done.
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Sun Jul 03, 2011 2:47 am     Reply with quote

Be sure I read datasheet.
But if you know all ATMEGA controllers have internal pull up/down system.
Of course the current is about 10-20uA for some devices.
Look for this example:
Code:

DDRA = 0x00;        //make port a as input

PORTA = 0xFF;       //enable all pull-ups
//or next line
PORTA = 0x00;       //enable all pull-down 

y = PINA;           //read data from port a pins

This example work with all Atmega.

Someone have a example to work with internal pull up/down digital input? Microchip
Thanks in advance.
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sun Jul 03, 2011 3:52 am     Reply with quote

Seriously, _what chip_.
You need to read the data sheet for the specific chip.

The point is that the PIC's _DO NOT_ have universal resistors. Most smaller/older ones only offer them on 'port_b' (port_b_pullups(TRUE); is the command to enable these). Latter chips with them still on port B, often allow then to be individually enabled (port_b_pullups(0b11110000); - turn them of for the high four bits). Some of the latter chips have them on other ports as well, and on these you get 'port_x_pullups', where x is the port name.
Then a _very few_ chips do have pull down resistors as well. On these you have:
port_x_pullups(upmask,downmask);
and here you could have:
port_a_pullups(0b11110000.0b00001111);
to enable pull 'down' on the low four pins, and pullup on the high four pins.

You need to talk about your specific chip. There are currently about 10* as many PIC based 'models' as there are Atmel, and the range of features is much larger, with the smaller chips in particular being much more 'cut down'.

Best Wishes
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Sun Jul 03, 2011 4:42 am     Reply with quote

PORTA = 0xFF; //enable all pull-ups
//or next line
PORTA = 0x00; //enable all pull-down

On a PIC with the CCS compiler this would not enable pull-up and pull-down RESISTORS, but it would use the pull-up and pull-down TRANSISTORS of the logic output stage. Make sure you know the difference.

Pull-up resistors (or current sources) are meant for "wired OR" situations where multiple devices may pull a line low, and the pull-up brings the line high when none of the other devices are active. Pull-ups can also be used to set the state of an unconnected pin.

If you use a pull-up transistor (the usual logic output set to "1") in a wired OR situation with another device pulling the line low you get a bad situation called "bus contention" which causes high current to flow, and if you do it for a whole byte the heat generated may even perminately damage the processor port.
_________________
The search for better is endless. Instead simply find very good and get the job done.
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Sun Jul 03, 2011 8:40 am     Reply with quote

yes Ttelmah
Code:
port_X_pullups (value) 

This example I need.
Thanks.

for SherpaDoug
I know that function work with AVR.
I don't tested on Microchip.
Thanks

Code:
PORT_X_PULLUPS

This example I need for my application.
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sun Jul 03, 2011 9:37 am     Reply with quote

Yes.

To SherpaDoug, this is a big difference with the Atmel chips. On a port set (via their equivalent of TRIS), as an _input_, the direction the pull-up/down's operate, is controlled by the contents of the output latch.
This has it's advantages, but also disadvantages. Obviously it does mean that every port can offer pull-up/pull-down, without needing separate registers, but you can't do the equivalent to the PIC on things like I2C, setting the TRIS as an input, and the driver to 'pull down', and then giving effectively 'open collector' drive, without having the pull-down resistor present, if you are using this on any other bit. It is a very different approach.

Best Wishes
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sun Jul 03, 2011 11:44 am     Reply with quote

Ttelmah wrote:
Yes.

To SherpaDoug, this is a big difference with the Atmel chips. On a port set (via their equivalent of TRIS), as an _input_, the direction the pull-up/down's operate, is controlled by the contents of the output latch.


If I may just clarify a little for Ttelmah,

PIC's have pullups (I've never seen pull-downs at all, but that doesn't mean it could change with newer devices -- so READ the Datasheet).

I'm currently working with a Samsung ARM core chip and it's GPIO's do have a configurable pullup/pulldown resistor system.

I think I've also seen configurable pullup/pulldowns on a Xilinx FPGA somewhere -- but to be specific, I'd have to go look it up again. I want to say Spartan3, but I could be incorrect.

Regardless, ALWAYS refer to the datasheet!!

Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Sun Jul 03, 2011 3:52 pm     Reply with quote

Some of the new 24E/33E chips have programmable weak pull-downs.
On older chips the only pins with this feature (that I know of), are the USB pins, where it is automatically enabled.

Best Wishes
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