Bob Barr wrote: > On the 16-series devices, so does avoiding the use of bit set/clear > operations on ports by rolling your own read-modify-write operation. > Reading the whole port in, modifying W as you need to, and then > writing the whole thing back works well in situations like this. That just creates your own manual version of the read-modify-write problem. The problem is that when reading the port bits, you get what the voltage is, not what the you are trying to set it to. The BSF and BCF instructions do a read, alter the indicated bit, then write the result back to the whole port register. This is exactly what you are doing the hard way. The problem can be avoided by keeping a shadow copy of the port register desired value. To change a bit, you first change it in the shadow register, then write the whole shadow register value to the port. In practise the read/modify/right issue isn't as big a deal as the endless discussions about it might lead you to believe. I have used shadow registers on isolated occasions, but most of the time it's easy to get around the issue as long as you're aware of it and understand it. If your external circuit holds the PIC pin in the opposite state the PIC is driving it for more than a few cycles, then there is likely something else wrong anyway. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu