At 02:16 PM 6/26/97 PDT, you wrote: >Hello, > I realize that we aren't supposed to use the TRIS command but I'm >working through the Easy PIC'n Guide and they use it for the first few >example programs. The problem is I'm not exactly sure what this command >does. I've read over the books description several times and I am still not >any closer to an answer. Can anyone out there give me a hand with it? I >just started with MPLAB, MPASM and the simulator yesterday so if you don't >mind nothing too heavy. > >Thanks very much, > > - Jason Halayko - > >Calian Communications Systems >Kanata, Ontario, Canada. Hi, The TRIS command allows you to transfer the contents of the W register into one of the TRIS registers (i.e. TRISA,TRISB, etc. ) which control whether each of the pins on the I/O ports act as an input or an output. For example, each bit in TRISA corresponds to a bit in PORTA whcih also corresponds to a pin on the PIC. So, to make pin RA1 an output, you must clear bit 1 of TRISA. It is not necessary to use the TRIS instruction because the TRIS registers can be changed just like any other register. However, the advantage to the tris command is that it does not require that you switch to register bank 1 before altering the TRIS registers. Remember, the registers on the PICs are in several banks. Register PORTB for example on the PIC16C84 is 06h. TRISB is 86h. You cannot simply say something like movwf 86h. You must switch to bank 1 and then say movwf 06h, the extra 80h being taken care of by the bank switch. The normal code to set TRISB is this: bsf STATUS,5 ;Switch to register bank 1 movlw 00000001b ;Set RB7-RB1 to output and RB0 to input movwf 06h ;Place in TRISB bcf STATUS,5 ;Back to bank 0 This could be written: movlw 00000001b tris 06h If your code will always be run on the PICs which are on the market now and does not need to be compatible with future Microchip products, you certainly can use the TRIS command. There is no other harm than a possible future compatibility problem. BTW there is one more instruction which Microchip recommends against using: OPTION. Option just moves the contents of W into the OPTION register. The advantage is the same as with TRIS. Option takes no arguments on the line with it. It just moves W into the OPTION register (addr 81h on the PIC16C84). Hope this helps, Sean