Christopher Head wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Jinx wrote: >>> So the following is safe and will never introduce a transient? >>> >>> MOVLW B'100' >>> IORWF PORTB,F >> I have a feeling that operations like IOR/AND/ADD/XOR etc would >> read the register first, leading to a possible r-m-w >> >> You should be safe with BSF and MOVWF though. Particularly if the >> port contents are read into a buffer or shadow register, modified, and >> then written back with MOVWF > > With respect to read-modify-write, BSF is not safe. BSF/BCF operate by > reading the port, altering the relevant bit, and writing the port. But what Jinx talked about was to execute the BSF/BCF against *another* register, not the PORTx register. And in that case it's "safe", of course. And "IORWF PORTx,F" isn't better than BSF/BCF in this regard. And, remember also that *no* operation that reads the PORTx register is safe. Remember that it is in the *read* phase the RMW is introduced. So this code (from another post) : > MOVF PORTB,W > MOVWF SHADOWB > MOVLW B'100' > IORWF SHADOWB,W > MOVWF PORTB isn't a single bit (!) better then a simple BCF/BSF, since it's in the "MOVF PORTB, W" that the error is introduced. The rest of the code can't do much about it after that, the SHADOWB register already has the error... > An > operation that definitively sets the value of every single bit (e.g. > movwf) is the *only* completely safe way to deal with RMW. Or that you has concideded the potential RMW issues and designed against it. That's isn't *that* hard either. Finaly, since the O.P said he might be using an I/O pin directly against the base of a standard transistor with no current limiting resitor, he might have problems, some which might look like the RMW problem. Jan-Erik. > > Chris > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.9 (GNU/Linux) > Comment: GnuPT 2.7.2 > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkkOqvsACgkQiD2svb/jCb6ixgCfWWtfTwAiKS1dh2M573SUbv20 > VQ0AnRoDqr6tEBt1SCV9DoZ5jF8z+KXl > =CpLH > -----END PGP SIGNATURE----- -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist