See notes below... /Jan-Erik. James Nick Sears wrote : > This is what I am not sure about though. Let me give an > example to explain > where I am not clear. > > Say for simplicity we are concerned with RD0: > > So when the reference is off (initial condition) we have: > TRISD = xxxxxxx1 (x = don't know/care) > PORTD = xxxxxxxx > > But RD0 as an input will sample the low voltage from the > unpowered IC input > and put PORTD,0 to 0 so we have: > TRISD = xxxxxxx1 > PORTD = xxxxxxx0 > > Now it's time to power up the IC - there are two options: > (1) > Set PORT register before TRIS register: > Set PORT register: > TRISD = xxxxxxx1 > PORTD = xxxxxxx1 > > Right here is where my question arises. Since there is a low > voltage connected to the pin which is configured as an input, > then won't the PIC just sample the pin low and overwrite the > change I just made? No, the PIC doesn't "sample" anything if you don't ask it to, by executing some instruction that *reads* PORTD. Note that, as shold be clear from the data sheet, the write-part and the read-part of PORTD is actualy two different things. And there is no direct connection between them either then by doing a read/write from your code. > > So if I set TRISD = xxxxxxx0 > PORTD might already be overwritten to = xxxxxxx0 Overwritten by what ? Only if your code does something that writes to PORTD ! Such as doing a BCF/BSF to *ANOTHER* PORTD-pin, which is exactly what all this r-m-w thing is all about ! Regards Jan-Erik. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu