Reading by itself the port should not change the output latches. The problem only starts when you want to modify another pin with an RMW type of operation such as logical operators like OR / AND / XOR. Then it reads the entire port first, modifies the bit you want, and writes all the bits back to the latch. So if that point if another pin was in input mode and it read as HI, then it will be written back to the latch as a HI state. Now when you change the TRIS back to output, the pin will be in that state. In 18F there is a latch register which is separated from the port pins so the input state will not affect the RMW operations when you operate on those. If you have a register and CPU cycle budget for that, you can keep a shadow register for each ports and just before changing the TRIS you can transfer that register to the port latches so you will have no surprises. Tamas On 6 December 2013 10:19, Dwayne Reid wrote: > Good day to all. > > I've been a long-time PIC programmer and thought that I knew all > there was in regards to Read-Modify-Write issues with early PICs > (12-bit and 14-bit core devices). But I'm doing a re-write of an old > project and ran into a question that I don't have an answer for. > > The situation is this: PIC pin is set as output and is low. Now I > turn the pin into an input and read the level on the pin. This level > might be HI or LO. Now I turn the pin back into being an output. > > Question is: what is the (output) level on the PIC pin *if* the level > had been HI when the pin was read? > > In other words, pin output latch used to contain a logic LO. The pin > was turned into an input and read a logic HI. Does the pin output > latch update to reflect the level that was read when the pin was an input= ? > > My gut says that the pin output latch *does* change from LO to HI. > > Any thoughts? > > dwayne > > -- > Dwayne Reid > Trinity Electronics Systems Ltd Edmonton, AB, CANADA > (780) 489-3199 voice (780) 487-6397 fax > www.trinity-electronics.com > Custom Electronics Design and Manufacturing > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .