|
|
View previous topic :: View next topic |
Author |
Message |
arrow
Joined: 17 May 2005 Posts: 213
|
Leaving Pins Unassigned- Current Drawn? |
Posted: Thu Sep 07, 2006 12:30 am |
|
|
Hi
I read somewhere (cant remember now where), that if the unused pins are left unassigned, there might be extra current drawn.
Is this true?
If yes, can someone please tell me how to assign pins of whole ports?
What about unused A/D pins?
Thank you
a. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
|
Ttelmah Guest
|
|
Posted: Thu Sep 07, 2006 2:50 am |
|
|
This applies basically to all logic families. In general, the gate connected to an input pin, can draw slghtly extra current, if it is sitting in an 'indeterminate' state. You get transistors biased 'half on', and sometimes can get oscillation. On outputs, depending on the logic family, normally there is slightly less power drawn with the output driven in one direction (often high).
Now on some older families (TTL for example), the input structure of the gate, itself tends to pull the input in one direction (for TTL, high), and this helps to prevent the problem. However it does mean that extra current is drawn when you want to drive the input 'low', and for the best behaviour, you are still advised to tie the inputs 'high' with a resistor. The assymetry of the behaviour for this family, can be seen in the Iih, and Iil figures (currents needed to draw an input high/low), which differ typically by over 100:1.
On the PIC, these currents are normally the same, so you can pull a pin high or low. Now you should use a resistor (rather than 'hard wiring' the pin to a supply rail), since this can prevent two seperate problems. The first is if your code accidentally programs the pin as an output, this limits the current being drawn, and the second is that if there is any time lags on the sequencing of power inside the circuit, this prevents driving the input into latch up (used to be a big problem on CMOS circuits, but most are now protected against this). On the PIC, you can also simply turn on the output driver, and provided nothing is connected to the pin, this will serve to pull the pin towards one rail.
Analog pins, have massively less of a problem in this regard, but will still tend to have slight variations in current, if they are allowed to float. in general though, there is no reason to ever have an unused analog input pin. Simply set the pin as an output, and this then overrides the peripheral, and drives the pin.
Generally, having high impedance pins floating, is something that should be avoided in all circumstances for good reliability, as well as power consumption.
Best Wishes |
|
|
arrow
Joined: 17 May 2005 Posts: 213
|
|
Posted: Thu Sep 07, 2006 3:08 am |
|
|
Hi Ckielstra and Ttelmah
Thank you for your responses!
I knew I saw it before!!
Is there any way to set all the pins on a port to output with one command?
And is there a way to assign all the pins to "L" with one command?
If I subsequently use some of these output pins as input, do I have to reassing them, or can I go ahead and use the "input(PIN_XX)" command?
Regards
a. |
|
|
Ttelmah Guest
|
|
Posted: Thu Sep 07, 2006 3:55 am |
|
|
All pins. Easy, look at the 'OUTPUT_X' commands (where 'X' is the port name). So 'OUTPUT_B(0)', will set all the pins of port B low.
A lot depends on the 'IO mode' you are using. Assuming you are using 'standard_IO' (the default), this will set the TRIS for the port to 0, and the code will automatically change an individual bit of this if you subsequently perform an input on an individual pin. If you are using one of the 'manual' tris modes, then you will have to control this yourself.
Best Wishes |
|
|
|
|
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
|