tris question for the 16f876


Closed Thread
Results 1 to 11 of 11

Hybrid View

  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.

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