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

SINGLE PIN SWITCH/LED DRIVE

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



Joined: 20 Apr 2007
Posts: 5

View user's profile Send private message

SINGLE PIN SWITCH/LED DRIVE
PostPosted: Fri May 18, 2007 3:06 am     Reply with quote

Hello

I am trying to use a single pin to drive an led and read a switch on the 16F870 chip. I can get this to work on PORTB but no matter what I do I can't get it to work on either PORTA or C.

Any help please.

Ian
TTelmah
Guest







PostPosted: Fri May 18, 2007 5:08 am     Reply with quote

It'd help if you described the actual circuit involved....
I find it hard to visualise a circuit to perform both functions on a pin, without resulting in poatential harm to the PIC.
Big difference, when it comes to 'reading a switch', is that PORTB, has pull up resistors internally available, when none of the other ports have these.
Remember that RA4, has no internal pull up gate either. PortC, and PortD, have Schmitt trigger input buffers, which will switch at different points from the TTL buffers on PORTA, and PORTB.

Best Wishes
bowler32



Joined: 20 Apr 2007
Posts: 5

View user's profile Send private message

PostPosted: Fri May 18, 2007 6:53 am     Reply with quote

Thanks for the reply.

I am driving the led through a 470R to 0ve and I have got a 4K7 pull up to 5volts for the switch.
I have tried different values for the pull up resistor for the differences between TTL and Schmit voltage levels.

I am polling the switch at 50ms intervals.

The internal pullups are disabled on portb.

Ian
Ttelmah
Guest







PostPosted: Fri May 18, 2007 8:16 am     Reply with quote

So, if the switch is made, while the PIC is driving the LED, the output gets shorted out, potentially overloading the output driver...
Though PICs are quite tough in this regard, it will result in nasty spikes of current on the supply rail, and could cause chip damage.
Double check that both Vss/Vdd connections are made to the chip. There can be some odditie like this if one is not properly made.

Best Wishes
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat May 19, 2007 2:45 pm     Reply with quote

Quote:
I can get this to work on PORTB but no matter what I do I can't get it to work on either PORTA or C.

It is difficult to help you if you do not posted any code.

Anyway, be aware that PORTA by default is an Analog Input after power-up and
one of them (RA4) is an open drain type.
Regarding PORTC, some pins are shared with other internal modules like UART and
TIMER1 and some directive to use them will override your pin direction definitions.


Humberto
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