Author Topic: A faulty pin?...  (Read 3436 times)

0 Members and 1 Guest are viewing this topic.

Offline Tricka90

  • Regular Contributor
  • *
  • Posts: 50
A faulty pin?...
« on: October 02, 2013, 06:18:52 pm »
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?
 

Offline alanb

  • Frequent Contributor
  • **
  • Posts: 342
  • Country: gb
Re: A faulty pin?...
« Reply #1 on: October 02, 2013, 06:25:46 pm »
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?
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: A faulty pin?...
« Reply #2 on: October 02, 2013, 07:05:27 pm »
Quote
Do you think I'm doing something wrong?

1) 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.
================================
https://dannyelectronics.wordpress.com/
 

Offline Tricka90

  • Regular Contributor
  • *
  • Posts: 50
Re: A faulty pin?...
« Reply #3 on: October 02, 2013, 07:30:08 pm »
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
 

Offline Tricka90

  • Regular Contributor
  • *
  • Posts: 50
Re: A faulty pin?...
« Reply #4 on: October 02, 2013, 09:13:34 pm »
I use MikroC as compiler
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2607
  • Country: au
Re: A faulty pin?...
« Reply #5 on: October 02, 2013, 10:39:19 pm »
You need to turn off the analog inputs as they are on by default.  Check the data sheet for the ADCON1 register.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: A faulty pin?...
« Reply #6 on: October 02, 2013, 10:41:11 pm »
Quote
The other pin works perfectly, also the pin on the same port.

Not sure what "the pin" is. But if other pins on the same port works, then the possibility of a hardware issue has increased.
================================
https://dannyelectronics.wordpress.com/
 

Offline Tricka90

  • Regular Contributor
  • *
  • Posts: 50
Re: A faulty pin?...
« Reply #7 on: October 03, 2013, 07:05:34 am »

Not sure what "the pin" is. But if other pins on the same port works, then the possibility of a hardware issue has increased.

I'm sorry, I mean all other pinS.  Yes, they do work, all the pins on the same port
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 3613
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: A faulty pin?...
« Reply #8 on: October 03, 2013, 07:22:10 am »
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.

Offline Tricka90

  • Regular Contributor
  • *
  • Posts: 50
Re: A faulty pin?...
« Reply #9 on: October 03, 2013, 07:51:04 am »
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?
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8229
  • Country: 00
Re: A faulty pin?...
« Reply #10 on: October 03, 2013, 08:17:55 am »
RA4 is OD.

Read the datasheet>
================================
https://dannyelectronics.wordpress.com/
 

Offline adam1213

  • Regular Contributor
  • *
  • Posts: 119
  • Country: au
Re: A faulty pin?...
« Reply #11 on: October 03, 2013, 08:24:33 am »
RA4 is OD.

Read the datasheet>
As 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf