The bit operations work as a read modify write. If you try two consecutive bit set instructions it is possible that the second one will execute prior to the first ones effect on its port line can overcome line capacitance. By using a dummy register to perform these bit manipulations followed by a mov command to shove the mirrored register to the output port you can avoid the read modify write problems. Bit banging usually refers to brute force manipulation of I/O pins to perform something like serial communication instead of using a part with a build in USART to perform the operation in hardware while the software is doing something else. This allows a lower cost part to be used if you have instruction cycles to burn for "software virtual peripherals". At 07:01 PM 6/18/98 EDT, you wrote: >I found a reference in a book I have by Mike Predko that talks about the >problem using BSF and BCF that a read takes place and if the line is pulled >high via another device, it will be set high after the read takes place. I >believe that exactly what one of my problems may be. I am not sure what the >simpliest way is to solve this problem because I use the BSF/BCF instruction >throughout the PIC serout routine which is timing sensitive. > >Am I to understand using the MOVLW AND MOVWF PORT,B or the AND (other) command >will not inadvertently alter the pin states? > >Should I rewrite all my routines to eliminate BSF/BCF instructions? > >What is the most efficient way to alter a single output line? For example if I >want to set portb,5 high what instructions can do this efficiently without >altering the other pin states? Maybe the AND command? Could someone provide an >example? > >By the way I am not sure what the term "bit banging" means. I think it means >bit manipulation using instructions such as RRF,RLF, AND, OR etc. and not MOV >or SWAP etc. Am I correct? > >Thanks > > Larry G. Nelson Sr. mailto:L.Nelson@ieee.org http://www.ultranet.com/~nr