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

Why are all my pins high with set_tris_a(0xFF) -PIC 16f877A

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



Joined: 29 Aug 2012
Posts: 17

View user's profile Send private message

Why are all my pins high with set_tris_a(0xFF) -PIC 16f877A
PostPosted: Thu Aug 30, 2012 2:07 am     Reply with quote

When I do set_tris_a(0xFF) for setting all the pins of port A on my PIC16F877A as input. They are all high. I thought they are still in analog mode.So I did the following
Code:
 
 setup_adc( ADC_OFF );
setup_adc_ports(NO_ANALOGS);
   set_tris_a(0xFF);

However they are still high. Why is that ?


Last edited by rajeshkhan808 on Thu Aug 30, 2012 2:30 am; edited 4 times in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19350

View user's profile Send private message

PostPosted: Thu Aug 30, 2012 2:21 am     Reply with quote

What PIC....

Normally:

setup_adc_ports(NO_ANALOGS);

but the syntax does change between chips.

Best Wishes
rajeshkhan808



Joined: 29 Aug 2012
Posts: 17

View user's profile Send private message

PostPosted: Thu Aug 30, 2012 2:22 am     Reply with quote

Hi , thanks for the reply just edited the question. I am using PIC16F877A
Ttelmah



Joined: 11 Mar 2010
Posts: 19350

View user's profile Send private message

PostPosted: Thu Aug 30, 2012 2:42 am     Reply with quote

Obvious thing is something external pulling them up....

Remember that a 'input' pin, has a very high impedance, and will sit for minutes, at the voltage it was last 'at', if nothing else is connected. It is up to whatever you connect externally to pull them to the required level.

Now, on some of the pins (A4, A5), you have the comparator outputs, so this needs to be disabled (setup_comparator(NC_NC_NC_NC)).

Best Wishes
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Thu Aug 30, 2012 3:03 pm     Reply with quote

If you are still really stuck, post SHORT complete compilable code which shows the problem.

Also quote version No. and see forum guidelines.

Mike
benoitstjean



Joined: 30 Oct 2007
Posts: 553
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Fri Aug 31, 2012 6:07 am     Reply with quote

Put some 4.7K resistors on each pin to GND. That'll solve the problem. If you don't, then the pins somewhat act as "antennas" and will react to whatever it "captures" so just rubbing your finger on a pin will make it change state. If you connect a 4.7K to GND, then the inputs are pulled low and will remain low until you send it a high level.
rajeshkhan808



Joined: 29 Aug 2012
Posts: 17

View user's profile Send private message

SOLVED
PostPosted: Fri Aug 31, 2012 6:42 am     Reply with quote

@benoitstjean
Thanks that solved the problem
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