Bob Barr wrote : > > On Sat, 10 Jan 2004 14:21:00 +0100, Jan-Erik Svderholm XA (TN/PAC) > wrote: > > >Hi. > >I don't remember what PIC you are using, but... > > > >On the 18-series you can write to the LATx regsiters > >instead of the PORTx registers. This should avoid some > >of these problems. I'd guess that what you are writing > >about is the read-before-write problems when using > >the bit handling instructions on port registers, where > >the read part will read whatever the pin is driven to by > >some external source, right ? > > > >The LATx regs in the 18-series solves this problem. > > > > 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. :=) Not sure. You are, in fact, still doing just the same thing as a BCF/BSF, but using your own code. *Any* read from a PORTx register, might have a bit driven to an *unknown* value by some external source. The only way to be sure, is to have a shadow register where *all* updates/writes are made, then write this register using MOVWF to the PORT regsiter. So there are never any reads from the PORT reg in this case. > > While the bsf and bsf opcodes certainly *can* be used on ports, > they're not the only (nor sometimes the best) way to change port bits. As everything, it depends, you just have to be carefull... Jan-Erik. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu