----- Original Message ----- From: "Olin Lathrop" To: Sent: Wednesday, May 22, 2002 8:48 AM Subject: Re: [PIC]: State of output drivers after a tris change > > > TRISB = 0 > > > PORTB = 0xAA > > > > > > TRISB = 255 > > > TEMP = PORTB > > > > > > TRISB = 0 > > > > > > After to port is set back to output what will be the state of the pins? > > > Does the contents of the output driver get destroyed when changing TRIS, > or when performing a read operation on the port? I'm hoping that my original > value ( AA ) is presented on the pins when I switch back to output mode. > > > > It should still be 0xAA because you did nothing to change the PORTB > > output value. > > Actually he did, so it won't be. TEMP = PORTB (assuming I interpret his > pseudo code correctly) reads port B while all bits are set as inputs. This > will essentially copy the input values to the output latches. The resulting > port B value therefore depends on the external circuit. > I don't think so ... As far I can see, this attribution line will be compilled as: MOVF PORTB,W MOVWF TEMP Note that the MOVF instruction isn't a RMW one. So it will only read the PORTB pins. There will not be any writes to the PORTB latches. My opinion is that after the TRISB=0, the output state of PORTB will be 0xAA again. Note that if there were any RMW instructions in the code, this wouldn't be true as the RMW instructions actually do a read before the write operation. Fabio -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads