tris question for the 16f876


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2008
    Posts
    15

    Default tris question for the 16f876

    for the 16f876, i need to know how to set the trisa. they give examples like trisa%11111111
    but trisa only has 6 ports on the 16f876. How do I state this?

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    It is
    Code:
    TRISA = %111111
    It reads from right to left. The right being PORTA.0
    So just use 6 places.
    Dave
    Always wear safety glasses while programming.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    $20 says that the next post says that the ports don't read correctly...

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    $20 says that the next post says that the ports don't read correctly...
    Is my answer wrong?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Your answer is spot-on Dave.

    But you can also use all eight bits in your TRIS statement, the upper bits of Ports that don't exist will simply be ignored.

    This certainly works for multi-family PICs like the 16F876 who has a bigger brother (the 16F877) that does have those pins, and the internal archetecture is shared. If the Datasheet says the Register has eight bits (even though some are unused), you can still send eight bits to that Register, the unused ones will just be ignored.

    The advantages are that is you ever migrate to the bigger PIC, your TRIS (and other Register) statements aren't going to throw you a curve-ball because you've accidentally left them undefined.

    Some PICs (like the 18F2520) have a PortE.3 all on it's own. In this instance you can set the TRIS bit on it's own, or you can still send all eight (or just four) bits to the Port, however all but E.3 will be ignored.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Well, my point was that the '876 has been obsoleted for awhile now, and most likely hard to get. And that the O/P might've actually meant '876A, which, as we all know, a LOT of newbs have trouble with PortA on that and many other PICs.

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    If the punter says he's got an 876, then we shouldn't make assumptions that he means the 'A' version. Likewise, he's asking about TRIS, so why make the assumption he's going to have other problems on that port? And why make the assumption that the PIC is hard to get... I've got a drawer full of them and so might other folks. Actually, purchasing here tries to vacuum up any they find on the market, because they're usually going real cheap as distributors try to off-load their stocks - it just means bigger profit margins on stuff you're selling.

    There's an old adage (which I teach people here) that goes "If you Assume, then it usually makes an ASS out of U and ME".

    Regardless of version, the setting of TRIS on the chips is the same which is all the thread was asking about.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    If the punter says he's got an 876, then we shouldn't make assumptions that he means the 'A' version. Likewise, he's asking about TRIS, so why make the assumption he's going to have other problems on that port? And why make the assumption that the PIC is hard to get...
    Leap of faith?

  9. #9
    Join Date
    Sep 2008
    Posts
    15


    Did you find this post helpful? Yes | No

    Smile

    Melanie, you are right, it is a 876 and not a 876a. And I did not know the the 876 has been replaced by the 876a. I'm new at this and bought some 876 chips cheep. Will the 876 program still work with the newer 876a? What are some of the things is need to watch for when switching to the 876a? Thanks so much.

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

  11. #11
    Join Date
    Sep 2008
    Posts
    15


    Did you find this post helpful? Yes | No

    Smile

    Hey great, this really helps me out. Good Job!!!

Similar Threads

  1. Hall Effect flow meter with 16F876
    By revelator in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th March 2010, 20:42
  2. Question from New member A/D input 16f876
    By mbruno in forum General
    Replies: 2
    Last Post: - 26th January 2008, 14:52
  3. Question for a math guru
    By Christopher4187 in forum General
    Replies: 3
    Last Post: - 22nd November 2006, 09:45
  4. Please answer my first question
    By John_001 in forum Off Topic
    Replies: 1
    Last Post: - 15th September 2006, 06:49
  5. Need help with migration 16F876 -> 18F252
    By NavMicroSystems in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th February 2004, 16:22

Members who have read this thread : 0

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

Posting Permissions

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