On Wed, 12 Dec 2001 12:00:05 +0600, James Paul wrote: > All, > > I have programmed a 12C509A to toggle 2 outputs out of pahse with one > another. It seems to simulate fine. And it runs in the processor fine > for a while. But when I connect a 1K resistor to each output through > a .1uF cap, both outputs wind up in phase. > > How can this happen? Anybody have any ideas? > > I have included the source file below for your perusal. > > Any ideas would be greatly appreciated. > Welcome to the wacky world of read-modify-write operations. When you perform the XOR on the port pins, three things have to happen: 1. the port *pins* are read 2. the XOR operation is applied to the data just read 3. the port *register* is written with the new data and it then appears on the output pins All of this happens in one instruction cycle with the read occuring in the first quarter of the cycle and the write occuring in the last. If you follow this XOR operation (shortly thereafter) with another one, the new data will not have had time to stabilize on the output pins before you read them for that second operation. =20 Operating speed and pin capacitance can greatly affect the reliability of r-m-w operations on I/O ports. (I generally avoid them if at all possible and it usually is.) You could try performing the XOR on a RAM location and then writing the RAM's contents to the port. Regards, Bob -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu