16f877 Unused Pins


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113

    Default 16f877 Unused Pins

    Hello all, I am working on a project and have a couple of questions. I am using theADC on port A to read a pressure sensor and....
    I've read that I should be tieing all unused pins on my 16F877 port a to ground with 10k ohm resistors. So far I am using RA0 as my ADC in and have set up RA1 and RA2 as output to trip my TTL relays. This is working well on my proto type board. I plan on adding on push button off of RB0 again this is working. I believe I set porta up correctly to accomplish this since the ADC is working and my relays are tripping as designed/planned. I set up ADCON1 below and in do I not have to set TRISA as well to be able to use RA1 and RA2 as output? I didn't misunderstand the datasheet did I?
    ADCON1 = %10001110
    TRISA = %00000001

    Secondaly since I am only using RB0 as an input should I make all the others input as well and tie them to ground as well with 10k resistors orjust leave them not connected to anything. I did tie RB0 with a pull up 10k resistor, that too is correct right?

    Not that those questions were novice enough I get worse. I am not planning on doing anything with any other pins so do I even care about setting or tieing portC and portd to anything at all?

    Thanks for your assitance.

    P.S. Normally I would just carry on my way experimenting on my own reading the data sheet but I've already fried 2 16F877's and don't want to fry anymore haha

    David

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's different school of thought on that, but usually what I do is to set all unused pin to input, and tie them directly to gnd. If I feel that I may need those i/o later, I may use resistors or jumpers to tie them to gnd.

    Some will set unused I/o as output, assign a level and let them float. In conjunction with a nice ground plane this might work.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    There's different school of thought on that, but usually what I do is to set all unused pin to input, and tie them directly to gnd. If I feel that I may need those i/o later, I may use resistors or jumpers to tie them to gnd.

    Some will set unused I/o as output, assign a level and let them float. In conjunction with a nice ground plane this might work.
    Mister e, Thanks. I tend to not like to have loose ends. I like the idea of tieing unused pins to ground. It's a little more design work but like you mentioned if you need it in the future it's much cleaner removing a resistor then trying to drill down into the board were no pad exists.
    Thanks
    David

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Some will set unused I/o as output, assign a level and let them float. In conjunction with a nice ground plane this might work.
    I make them outputs and tie them to ground through 10k. Inputs if somehow allowed to float make great antennas for noise / outputs on the other hand if somehow get switched on, increase your power consumption. Bottom line is tie them the way that works best for your application, but do not let them float.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Jan 2008
    Location
    Pennsylvania
    Posts
    113


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    I make them outputs and tie them to ground through 10k. Inputs if somehow allowed to float make great antennas for noise / outputs on the other hand if somehow get switched on, increase your power consumption. Bottom line is tie them the way that works best for your application, but do not let them float.
    It's sounds like the common denominator so far is tieing them to ground with a 10k. After that I can control via software if they are output or input. Which would work best for my application can be determined later.

    Thanks all

    David

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    having some resistor to pull them down have it's own advantage in case the software goes crazy, if you alter the TRIS setting by inadvertence, or while developing/debugging. Kinda bullet proof
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Sep 2007
    Posts
    19


    Did you find this post helpful? Yes | No

    Default LCD damaged by hardware/software?

    I use LCDOUT with DB4-DB7 on PORTB.0-PORTB.3, RS on PORTC.1, Ebit on PORTC.0 on 16F886. Starting BIT is set to 0. Will setting TRISB and TRISC even not set correctly can damage the LCD as well the PIC itself?

    example TRISB=00000000 and TRISC=00001111 as used before, works fine till I noticed something that TRISC shows last four inputs and I changed it to TRISC=00000000, the result is damaged. all are set for DIGITAL Modes (ANSEL).

    Does it have to have TRIS set correctly for use with LCD?

    I have about ten units running fine with TRISB=00000000 and TRISC=00001111 working fine, then the two units failed with modified TRIS's TRISC=00000000. Maybe the TRISB needs to be 11110000 and TRISC set to 00000011?
    Last edited by hvacrtech; - 24th September 2009 at 20:18. Reason: changes in wording

  8. #8
    Join Date
    Sep 2007
    Posts
    19


    Did you find this post helpful? Yes | No

    Exclamation It was the prgrammer U2 fault!

    Quote Originally Posted by hvacrtech View Post
    I use LCDOUT with DB4-DB7 on PORTB.0-PORTB.3, RS on PORTC.1, Ebit on PORTC.0 on 16F886. Starting BIT is set to 0. Will setting TRISB and TRISC even not set correctly can damage the LCD as well the PIC itself?

    example TRISB=00000000 and TRISC=00001111 as used before, works fine till I noticed something that TRISC shows last four inputs and I changed it to TRISC=00000000, the result is damaged. all are set for DIGITAL Modes (ANSEL).

    Does it have to have TRIS set correctly for use with LCD?

    I have about ten units running fine with TRISB=00000000 and TRISC=00001111 working fine, then the two units failed with modified TRIS's TRISC=00000000. Maybe the TRISB needs to be 11110000 and TRISC set to 00000011?
    AFter reading other forum, I put default for the programmer U2 and the problem solved! Now that my completed unit is back to life! The TRIS has to do nothing with for using with LCD but the unused pins information is excellent source for terminating unused pins via pullup or pulldown. I ususally set TRIS outputs for unused pins.

  9. #9
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by hvacrtech View Post
    The TRIS has to do nothing with for using with LCD but the unused pins information . . .
    I imagine . . . LCDOUT sets the tris like the HIGH and LOW functions do. Dig through the library if you are really curious to find out.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. 16F877A Pullups/Pulldowns and unused pins
    By DavyJones in forum General
    Replies: 6
    Last Post: - 17th April 2009, 02:39
  2. Change On Interrupt, PIC16F884
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 14th November 2008, 18:25
  3. Five unused pins and one resistor
    By Cabomba in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th May 2007, 19:07
  4. Unused pins
    By manxman in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 4th May 2007, 23:24
  5. Interrupts and Disable 16f877
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th April 2005, 22:08

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts