A faulty pin?... - Page 1
Forum section: electronics / general

author: Tricka90
author_rank: Regular Contributor
timestamp: October 02, 2013, 06:18:52 pm
content: I'm trying to light up a LED with a PIC 16F876 (datasheet:http://ww1.microchip.com/downloads/en/devicedoc/30292c.pdf) on port RA5. The LED just doesn't light up.I've set TRISA = 0 and PORTA.RA5 = 1 of course.In the datasheet I found that RA5 is also an analog port, so I set up all port as digital with ADCON1 = 0b00000110 and ADCON0 = 0.Still the LED doesn't work.Then I found that RA5 is also a "slave select for the synchronous serial port" so I tried to disabilitate this function with PIE1.SSPIE = 0 and SSPCON.SSPEN = 0.The LED continues not lighting up.Do you think I'm doing something wrong? Could it be that pin RA5 is just faulty?

author: alanb
author_rank: Frequent Contributor
timestamp: October 02, 2013, 06:25:46 pm
content: If you think that a particular pin may be faulty have you tried a different pin and updating your software for the new pin?Also have you checked that there is power to the PIC and that the clock is running etc?

author: dannyf
author_rank: Super Contributor
timestamp: October 02, 2013, 07:05:27 pm
content: Quote1) take a look at the pins and see what functions, other than gpio, they may have;2) turn those functions off.In your case, two additional statements will do.

author: Tricka90
author_rank: Regular Contributor
timestamp: October 02, 2013, 07:30:08 pm
content: Thank you for the answers.The other pin works perfectly, also the pin on the same port.The functions of RA5 are the ones I mentioned, I don't think it has other functions

author: Tricka90
author_rank: Regular Contributor
timestamp: October 02, 2013, 09:13:34 pm
content: I use MikroC as compiler

author: David_AVD
author_rank: Super Contributor
timestamp: October 02, 2013, 10:39:19 pm
content: You need to turn off the analog inputs as they are on by default. Check the data sheet for the ADCON1 register.

author: dannyf
author_rank: Super Contributor
timestamp: October 02, 2013, 10:41:11 pm
content: QuoteNot sure what "the pin" is. But if other pins on the same port works, then the possibility of a hardware issue has increased.

author: Tricka90
author_rank: Regular Contributor
timestamp: October 03, 2013, 07:05:34 am
content: Quote from: dannyf on October 02, 2013, 10:41:11 pmI'm sorry, I mean all other pinS. Yes, they do work, all the pins on the same port

author: AndyC_772
author_rank: Super Contributor
timestamp: October 03, 2013, 07:22:10 am
content: PICs are cheap, so swap the PIC for a new one and try that. If you don't have a spare, order at least 5 today, or 10 if you think you might be doing any future projects with the same device.Never, ever buy exactly enough cheap bits for a project... you'll end up paying more in shipping for replacements every time something breaks anyway. I always buy at least 'n+1' even of quite expensive bits, and often buy 5 or 10 of something I only need 1 or 2 of. If I need a chip today, chances are I'll need another one next week anyway.

author: Tricka90
author_rank: Regular Contributor
timestamp: October 03, 2013, 07:51:04 am
content: Thank you for all the help.I must say I'm really really sorry, I made a big mistake: the "faulty" pin isn't RA5...it is RA4 !!!This pin could also be used as T0CKI, that is Timer0 clock input.I have disabled the bits, now I have OPTION_REG = 0b100000010, just RBPU and prescaler because I would like to use Timer0 in my program.Why it still doesn't work? Should I set other bits?

author: dannyf
author_rank: Super Contributor
timestamp: October 03, 2013, 08:17:55 am
content: RA4 is OD.Read the datasheet>

author: adam1213
author_rank: Regular Contributor
timestamp: October 03, 2013, 08:24:33 am
content: Quote from: dannyf on October 03, 2013, 08:17:55 amAs the output is open drain you need to setup the LED such that it will go on when you set the output to 0. e.g. connect it to VCC through a resistor.