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 support@ccsinfo.com

Controlling floating pins
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

Controlling floating pins
PostPosted: Thu Aug 06, 2009 12:19 pm     Reply with quote

hello all,

I'm working on a small project, where the only requirements are to turn on and off 2 LEDs for debugging and communicate with a PC through RS232

I'm using a 16F877A... as you can see I am only using 4 pins on the chip.
2 LEDs and RX&TX

I'm having alot of problems with noise and static and I suspect most of my problems (resets and so on) are caused by floating pins.

I have set all my other pins as Outputs, using Set_Tris except the Usart input, in order to avoid my pins floating.

Is this Ok?

Thank you in advance.
_________________
CCS PCM 5.078 & CCS PCH 5.093
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

Re: Controlling floating pins
PostPosted: Thu Aug 06, 2009 12:30 pm     Reply with quote

Gabriel wrote:
hello all,

I'm having alot of problems with noise and static and I suspect most of my problems (resets and so on) are caused by floating pins.


That depends on where you are. If you are sitting in an electronics lab all day noise and static is not likely to cause your PIC to start resetting. I suspect there is something wrong with your hardware. Can you post your schematic?

Yes you can set the unused pins as outputs but using fast_io and set_tris. Or you can just use the standard CCS functions output_high() and output_low().
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Aug 06, 2009 12:53 pm     Reply with quote

If you consider my living room a lab and my dinner table a work bench... I guess I don't have any static problems hahahaha.

Its winter here... cold=coats=layers of coats= MASSIVE STATIC BUILDUP.

My code and my hardware work fine... but only when they want to.... I believe its because of noise... either from my power line.. or me being a freaking HV source of doom.

I am not using ICSP so I do have to touch my pic constantly....thus I think, the source of my problems.

I don't think I need fast io if I am only setting them as outputs...to avoid floating pins? Do I?

Will setting them high or low make any difference?

I am assuming setting them as outputs is better than inputs... to prevent noise and erratic behavior that is.


Thanks for your help

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Thu Aug 06, 2009 1:06 pm     Reply with quote

You can use output_high(your_favorite_PIN) or output_float() and then use a 50K resistor to GND. Or you can use output_low() or output_float() and use a 40K resistor to +5V.

I personally have not had issues setting unused pins as inputs (without any pullup or pulldown resistors) but since it is a practice that is frowned upon I will go with the book so to speak and suggest you do not use this method.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Aug 06, 2009 1:29 pm     Reply with quote

hmm...

I'm trying to avoid the resistors... because... hahaha i don't have any!
and by that i mean having to tie everything high or low...

I got very limited resources.... stores don't open after 7pm... i get off work at 7 pm... they don't open before 7 am... i go to work at 7 am....

and electronic shops... are not very fond of opening Saturday afternoon...
which i cant go to ethier..... cause I'm working....

I can jump all my pins to ground.... i do have jumpers hahahhaha


How about .. setting them all as inputs and tying them all to ground?

... I sent there like a tristate option.... that does exactly what i want?

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

got a schematic?
PostPosted: Thu Aug 06, 2009 2:57 pm     Reply with quote

got a PDF of the schematic - and info on your POWER supply?

using a MAX232 / HIN202 / similar RS 232 IFC ?

what is receiving your rs232 ? A pc ?

knowing that - i may better help u
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Mon Aug 10, 2009 8:28 am     Reply with quote

Gabriel wrote:
hmm...


I can jump all my pins to ground.... i do have jumpers hahahhaha


How about .. setting them all as inputs and tying them all to ground?



g

You want to avoid setting them as inputs if at all possible. If all you have are jumpers just tie them all to ground or 5V and use output_float().
gs



Joined: 22 Aug 2005
Posts: 30
Location: Ioannina - Greece

View user's profile Send private message Visit poster's website

PostPosted: Mon Aug 10, 2009 8:38 am     Reply with quote

Do you have any capacitors on the circuit? MAX232 produces some noise that needs filtering.
_________________
www.hlektronika.gr
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Mon Aug 10, 2009 11:03 am     Reply with quote

hello,

so what is the diference between just setting them as outputs Vs. output_float?

Quote:
You want to avoid setting them as inputs if at all possible. If all you have are jumpers just tie them all to ground or 5V and use output_float().


THAT is what a real answer looks like.... definitive and final. i like it..
thank you


i do have capacitors on my circuit... and enough filtering...
its the static thats killing me...
_________________
CCS PCM 5.078 & CCS PCH 5.093
Guest








PostPosted: Mon Aug 10, 2009 11:09 am     Reply with quote

Hi,

There were tons of suggestions/questions in this thread that you basically ignored. An answer is not necessarily 'definitive' just because it is what you want to hear.....

Dave
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Mon Aug 10, 2009 11:16 am     Reply with quote

Gabriel wrote:
hello,

so what is the diference between just setting them as outputs Vs. output_float?


Actually output_float() sets the pins as inputs (high-impedance). There is no single line function in CCS to set the pins as inputs. To do that explicitly you will use fast_io and then set the tristates themselves. The output_float() function basically sets them as inputs, which you will tie either high or low to avoid any noise on those pins which you may get by floating them.

If you use output_high() and then float the pins, a very realistic problem is you may accidentally short the pins to GND and you are screwed basically.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Mon Aug 10, 2009 11:24 am     Reply with quote

i didnt ignore anything...
and i am thankful for everybodys help... thats why i joined... to get helped. ignoring peoples suggestions would be against my own benefit.

i was just complimenting the user. his answer i thought was the most acurate for my situation... mabey he worded it better...


in anycase.. thank you all once again

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Mon Aug 10, 2009 11:36 am     Reply with quote

Mkuang:

so, i should avoid setting them as inputs....
but i should set them as output_float, which makes them inputs? hahahaha

i think i get it...

output_high / low... set them as outputs... common outputs...source/sink.

output_float ... is the high impedance "third" state if you may... (this answers a question on a previous post)...and they are basically inputs because inputs are also high impedance...

and setting them as inputs using tris... well.. they are inputs, and noise will kill me...

thats what you meant right?

using output_float, even though they are in their high impendance state i still have to tie them high/low?
i was under the impression that by setting them in this state... the pin basically became an open circuit... dead pin, N/C sort of thing...

thank you for you help

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Mon Aug 10, 2009 11:49 am     Reply with quote

I am sorry I should have worded it better. What I meant was you should avoid setting them as input as much as possible. HOWEVER, since all you have are jumpers and no resistors available, you can set them as inputs by jumpering them all to GND or 5V.

The two ways of setting them as inputs that I know of are:

1) using the output_float() function (yes the name sucks but that is what CCS calls it).

2) using the fast_io and set_tris functions.

Using either method the pin is an input.

A preferred way is to set them as outputs and use pull-up or pulldown resistors. But remember that never drive a pin high if you use a pullup and never drive a pin low if you use a pulldown. But since you don't have any resistors this is a moot point.

Also let me reiterate that I personally have not had problems setting unused pins as inputs and floating them. But that's just me and the kind of work environment I am in. Your experience may vary.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Aug 10, 2009 2:17 pm     Reply with quote

Seems like it has finally been clarified how to set unused pins to output.

It would be interesting to know, if this changes anything regarding your reported issues? Although I completely agree with the suggestion to avoid floating pins, I don't expect, that they cause any problem except additional current consumption (some mA).

Particularly, why should we expect problems with static electricity related to floating pins? Floating pins aren't connected to anything, it should be difficult for electrostatic discharges to enter a floating pin directly. If they would, either the existing on-chip protection diodes are capable to absorb it or they can't. But don't assume, that enabling the low or high driver of the respective I/O pin changes the path of the several 10 A discharge current. Without feeding considerable currents to a floating pin, the level always stays within the limits set by the chip's substrate diodes, supply voltage +/- 0.6 V.

In most cases, where electrical interferences or "noise" are affecting a single chip processors's operation, they are causing voltage drops or peaks at the supply pins or possibly hitting the reset input directly.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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