Hi Folks, Brett Rosner sent me a message asking questions about the book. When I tried to reply to him, the file system that he is connected to said he doesn't exist. So in the hopes that he is on the list: Hi Brett, To answer your questions: >Hello, >I have purchased your book "Programming & Cutomizing the PIC >Microcontroller" and I have a quick question. I have the hard cover >copy. The top of page 174 has code to set the RB0 bit to be an output >bit. > >1) The latest data books from Microchip continue to use the tris command >in all their examples. Will this command really be eliminated, or have >they decided to keep it? Which databooks are you talking about? In all the databooks I have, when you look at the "TRIS" Instruction Description, you get the "Description": "The instruction is supported for code compatibility with the PIC16C5X products. Since TRIS registers are readable and writeable, the user can directly address them." And, in a box is the message: "To maintain upward compatibility with future PIC16CXX products, do not use this instruction." So, really according to Microchip, you shouldn't be using the "TRIS" or "OPTION" (which has the same warnings) instructions. I'm curious to know who told you differently, or where you read that. To be honest, I have found many example applications (including in Microchip databooks), the "TRIS" and "OPTION" Instructions are used more than setting RP0 (not "RB0" as you've quoted), changing TRIS/OPTION and then resetting RP0 (probably because this only requires one instruction). But, using "TRIS", means you can't do funky things like: >2) The real question: I am confused when you use > >bcf TRISB & 0x07F, 0 > >Why is TRISB anded with 7F Hex? It looks like the direct addressing of >the registers uses 7 bits in the address and the RP0 for the eigth bit. >Are you just truncating the address to indicate that only 7 bits are >used for direct addressing? If so, then why haven't all the register >addressed been truncated in the same manner? If you look at the include file for the 16C/F84, you'll see that "TRISB" is given the value 0x086, but the instructions can only take a 7 bit address. If you don't AND it with 0x07F, then you will get a warning message saying that Bit 7 is set. If you look at the sub-chapter "The STATUS register" starting on Page 29, you should get the answers you are looking for (starting on Page 30 for the Bank Specific information) as well as an alternative way of changing Bank 1 registers (in "Register addressing" starting on Page 31). >I have looked for the answer to this question in your book and have not >found it. The fact that the Microchip staff continues to use "tris" has >not given me any help in resolving this matter. Understanding the mid-range PIC's (and, actually the low and high end PIC's) register banking can be really confusing and is probably the second most difficult thing to learn how to modify (the first is the PCLATH Registers). This is why I've put in a number of examples of how to do it in the book (PROG2 starting on Page 172 which shows the Bank Switching Method of modifying TRIS Registers, PROG13 starting on Page 205 uses "TRIS" instead of accessing the registers, PROG31 on Page 230 shifts the TRIS register value to show how the TRIS register can be written to/read from to change an (analog) output Voltage. Good luck and please let me know if you have any other questions, myke >Take care, >Brett Rosner >brosner@impulse.net > > "Programming and Customizing the PIC Microcontroller" is the January 1998 Electronics Book Club Main Selection. See "http://www.myke.com".