PDA

View Full Version : output port issues driving LEDs



p15218
- 26th August 2008, 19:44
With a 16F690 and PBP, I’m having a problem driving simultaneous port outputs which are connected to LEDs via individual 2k Ohm resistors to ground.
With this first bit of code, I can illuminate one or two LEDs as one would expect.

Trisc = %00000000

Portc = %00000001 ‘ lights the first LED
Pause 1000
Portc = %00000011 ‘ lights both LEDs

Now, the below code SHOULD do the same thing as the above code which is
light the first LED then light the second LED while not turning off the first LED.
Nope, the first LED gets extinguished.

Trisc = %00000000

Portc.0 = 1 ‘ lights the first LED
Pause 1000
Portc.1 = 1 ‘ the first LED goes dark and the second LED lights!!!!


I have found some other older posts that talk of this same issue but they were running several LEDs with one dropping resistor which turned out to be their problem.
I have a separate resistor for each LED.

HELP!

Bob

jderson
- 26th August 2008, 20:39
May I suggest that 2K ohms is way to high a value? Use something more like 300 ohms.

Darrel Taylor
- 27th August 2008, 05:39
Portc.0 = 1 ‘ lights the first LED
Pause 1000
Portc.1 = 1 ‘ the first LED goes dark and the second LED lights!!!!


It's the never ending problem. :eek:

OK well, it will end for you when you add this to your program ...

ANSEL = 0

But for us, it will never end. The word will never get out. "Turn off the Analog ports".

Microchip is a cruel vicious company bent on driving us crazy by ENABLING analog functions by defualt.<hr>

Sorry, I was watching the political convention on Tivo and felt like being over-dramatic for no reason at all. :D

Melanie
- 27th August 2008, 08:58
Microchip is a cruel vicious company bent on driving us crazy by ENABLING analog functions by defualt.

Yes, but has anyone noticed that they're not even sensibly enabled 'by default'? Posted by videophone onto a big screen from the back of a dodgy hotelroom in Kansas).

Bruce
- 27th August 2008, 15:02
FYI: The reason this happens;


Portc.0 = 1 ‘ lights the first LED
Pause 1000
Portc.1 = 1 ‘ the first LED goes dark and the second LED lights!!!!

is because you're using a read-modify-write type command with Portc.0=1
so when the PortC is read on the 2nd Portc.1=1, Portc.0 is read again, and
it's read as zero, since A/D is enabled, so it goes low on the next port bit
change.

Melanie: What the heck are you doing in Kansas...;o}

SteveB
- 27th August 2008, 20:22
It's the never ending problem. :eek:

But for us, it will never end. The word will never get out. "Turn off the Analog ports".

Microchip is a cruel vicious company bent on driving us crazy by ENABLING analog functions by defualt.<hr>

Sorry, I was watching the political convention on Tivo and felt like being over-dramatic for no reason at all. :D

What I don't understand is: Why do so many people miss this? Thinking back to my PIC infancy, it is this very thing which I can recall learning. The first step in any program. Setting up the ports to work they way I want. Analog, Digital, Input, Output, Pull-up, CCP, .... Whatever. It's plastered everywhere! I could hardly read a post, manual, datasheet, PIC book, etc. without seeing this problem and the solution.



.....



I'm done. Stepping down. Deep breath. :o

SteveB

Melanie
- 27th August 2008, 21:42
No, not in Kansas... I was just making fun of the convention following Darrels comment... though I was in Southern California for a short while a month back... baby-sitting of all things - Don't ask!!!