Tris Register use.


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Oct 2006
    Posts
    6

    Default Tris Register use.

    I am new to the forum and trying to interface a 16F877 to a GE 90-30 PLC with Shiftin/out. My first question as I start this, is this. I have read in the past in the data sheet I think that to be compatible with future versions of the PIC that we are not supposed to use the Tris command. Could someone verify this for me and tell me what I am supposed to do in its place. Sorry about the previous post to the FAQ, this is my firs post.

  2. #2
    Join Date
    Oct 2006
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Found the statement in the data sheet.

    It reads, Note: To maintain upward compatibility with future PIC16F87XA products, do not use the OPTION and TRIS instructions. So the question, what do I use in place of the TRIS instruction?

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    The TRIS Command in question is an assembly level command and not a PBP command.

    With the 877, if you write “TRISA=7”, for example, you are not using the TRIS command but loading the TRISA register directly. PBP takes care of all these issue for you so no worries.

    ASM Equivalent of what TRISA=7 does
    MOVLW 007h
    MOVWF TRISA

    ASM Equivalent using TRIS command - PBP does not do this (and this may not be supported on the 877?)
    MOVLW 007h
    TRIS PORTA
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    Join Date
    Oct 2006
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Thanks for clearing that up for me!!

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    I did not hear that and can not confirm.

    But, since we are in PBP forum, you can use INPUT and/or OUTPUT commands to do what TRIS does.

    Example:

    TRISA.1 = 1
    'make PORTA.1 an input pin.

    same as

    INPUT PORTA.1
    'Make PORTA.1 an input pin.


    or

    TRISE.2 = 0
    'Make PORTE.2 an output pin.

    same as

    OUTPUT PORTE.2
    'Make PORTE.2 an output pin.



    -------------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    (and this may not be supported on the 877?)
    Just for completeness, it appears the TRIS assembly command works on the 16F877 for PORTS A,B, and C, but not PORTS D or E.

    Thr following works but gives warning "Use of this instruction is not recommended"

    Code:
    ASM
        movlw   0x07
        TRIS   PORTA
    ENDASM
    and this
    Code:
    ASM
        movlw   0x07
        TRIS   PORTD
    ENDASM
    gives errors.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  7. #7
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    From PIC16F87X Data Sheet DS30292C-page 135, section 13.0 INSTRUCTION SET SUMMARY

    Note: To maintain upward compatibility with
    future PIC16F87X products, do not use the
    OPTION and TRIS instructions.
    Patient: Doctor, it hurts when I do this.

    Doctor: Then don’t do that!
    TRISA= {value}
    TRISB= {value}
    TRISC= {value}
    TRISD= {value}
    TRISE= {value}

    Are all valid PBP statements and may/should be used to set TRIS directly (as they will take care of any required bank setting, ect).
    Last edited by ErnieM; - 24th October 2006 at 18:47.

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


    Did you find this post helpful? Yes | No

    Default

    if you really want to use ASM in PBP, and don't want to look where TRIS or else register is located...
    Code:
    asm
        CHK?RP TRISA ; PBP BANK switching macro
        movlw d'7'
        movwf TRISA
    endasm
    Steve

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

Similar Threads

  1. Active low input?
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th August 2010, 20:31
  2. Can anyone help a newcomer?
    By scopit in forum Schematics
    Replies: 18
    Last Post: - 20th October 2009, 09:23
  3. PIC16F877A pwm use for IR transmission
    By mcbeasleyjr in forum General
    Replies: 0
    Last Post: - 11th July 2009, 18:51
  4. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07
  5. MX7705 or AD7705 experience
    By FM11 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 12th January 2006, 21:54

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